Could not find an example for this one and hought I'd share what I came up with.
Correct me if I've missed something.
Problem: efficiently wait for a long running non-child process
(example -- started a large copy and wanted a noise when it was done.)
inotifywait doesn't do well with /proc/<pid> but I still used it to be just
a little more efficient and timely than a shell loop:
===============================================
#! /bin/sh
# waitfor a process
PID=$1
shift
[ -e /proc/$PID ] || { echo No process, $PID; exit 127; }
while inotifywait -qq -e CLOSE /proc/$PID/exe && [ -e /proc/$PID ]
do
:
done
$*
===============================================
I use it like this:
waitfor 14471 play /media/WeirdAlYankovic/DareToBeStupid/09_This_Is_The_Life.flac
--
Gerry Skerbitz
gsker at skerbitz.org