Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Wait for other process to finish (See related posts)

# There's another process you want to wait on.  In this example,
# you know the pid, and it's contained in the file $PID_FILE.
while ps -p `cat $PID_FILE` > /dev/null; do sleep 1; done

# Now you can continue knowing that process has finished...

Comments on this post

Quaestor posts on Jun 19, 2007 at 07:21
If the process is a child of the current shell, just use
wait $pid


Otherwise, use
kill -0 $pid >/dev/null
.

You need to create an account or log in to post comments to this site.


Click here to browse all 4852 code snippets

Related Posts