[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] bash pid



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/