[ale] bash pid

Ed Cashin ecashin at noserose.net
Wed Mar 24 16:54:19 EDT 2010


You can use backgrounded processes and "wait" as shown below.
Otherwise, the process has exited before your script gets control again,
making the pid unusable.  Or I'm missing the point.  :)

In this example the alarm going off represents some condition like
the foreseen "probable kill needs".

me=$$
sh -c "sleep 5 && kill -USR1 $me" &  # alarm in 5 seconds
sleep 20 &
job=$!
trap "echo kill $job" USR1
wait $job || echo "aborted pid $job" 2>&1

-- 
  Ed Cashin <ecashin at noserose.net>
  http://noserose.net/e/
  http://www.coraid.com/


More information about the Ale mailing list