On Wed, 3 May 2006, Moshe Kaminsky wrote:

* Jorge Almeida <[EMAIL PROTECTED]> [03/05/06 19:30]:
On Wed, 3 May 2006, Moshe Kaminsky wrote:

You can use 'kill 0' to send a signal to your own process group.
Something like this:

#!/bin/sh
trap 'kill 0;exit' TERM
echo "before"
( sleep 30; echo inside )
echo "after"

No use. trap will wait till the running child is completed, which is not what
I want (as reply of Hans-Werner).

Well, I just tried it, and it worked.

You mean the parent received the TERM signal while sleep'ing 30 and the
child terminated before the 30 seconds were through?
I intend to use the script with a long rsync, which must terminate when
receiving the signal.
I tested your script with 3000 instead of 30, and the script outputs
"after" and terminates when I send it a TERM; however, a process "sleep
3000" still comes out in the output of ps auxf (as an orphan), I had to
kill it explicitly.

Jorge
--
gentoo-user@gentoo.org mailing list

Reply via email to