[ale] bash pid

Jim Kinney jim.kinney at gmail.com
Sun Mar 28 12:20:22 EDT 2010


Actually, the processes are very long lived. So the rework will involve
either a tee or a subshell so the main process can watch trhe sub and kill
it after a max time elapses. Clearly not going to work as briefly demo'd in
original post.  Many thanks to all for making me rethink this.

On Mar 24, 2010 5:05 PM, "Ed Cashin" <ecashin at noserose.net> wrote:

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/
_______________________________________________
Ale mailing list
Ale at ale.org
http://mail.ale.org/mailman/listinfo/ale
See JOBS, ANNOUNCE and SCHOOLS lists at
http://mail.ale.org/mailman/listinfo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20100328/8c44f161/attachment.html 


More information about the Ale mailing list