APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

wait4path

This is one of those odd commands that somehow make their way into standard distributions. Its obvious intent is to wait for some file system to mount: it just sleeps and doesn't return until it is. You can't really use it for ordinary directory watching (see Monitoring file or directory changes below if you need that) because it only checks when the mount table is updated. So you can do "wait4path /not_here_yet" and it will sleep, but it won't wake up and return just because you "mkdir /not_here_yet". If you subsequently mount or unmount any file system, it will wake up and notice /not_here_yet, but not until then.

Therefor its obvious use is in a startup script that needs to hang on until some specific filesystem is mounted. Is it actually used in OS X? Well, not on my MacBook, but there's nothing being mounted there it would need to wait for. If I had a server here, and user's directories were there, maybe it would make use of this.

You could use this as a cheap notification of mount/unmount events:



#/bin/bash
rm -rf /tmp/foobah
while :
do
# not foolproof
bash -c "sleep 1;mkdir /tmp/foobah" &
wait4path /tmp/foobah
rm -rf /tmp/foobah
mount
echo "Something changed"
done

Though at the moment I can't think of a good reason that would make you want to.

Monitoring file or directory changes



Got something to add? Send me email.


1 comment



Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Anthony Lawrence







Tue May 8 06:25:37 2007: 2992   anonymous




Try mount -u <an already mounted mount-point>, e.g.


Process 1:
wait4path /tmp/foo

Process 2:
mkdir /tmp/foo

mount -u /



The only side effect I'm aware of is that you get a seemingly innocuous syslog entry like the following:


Mmm dd hh:mm:ss host KernelEventAgent[PID]: tid 00000000 received unknown event (256)





------------------------
Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





FORTRAN—the "infantile disorder"—, by now nearly 20 years old, is hopelessly inadequate for whatever computer application you have in mind today: it is now too clumsy, too risky, and too expensive to use. (Edsger W. Dijkstra)





This post tagged: