* Jorge Almeida <[EMAIL PROTECTED]> [03/05/06 23:30]:
> 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.

Funny, I just tried the same, and it worked. It also didn't print any 
"after" (appropriately, since the sig handler includes 'exit'), and I 
didn't find any sleep process. Maybe it was from some different 
experiment?

Moshe

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

-- 
I love deadlines. I like the whooshing sound they make as they fly by. 
                                        -- Douglas Adams
    
    Moshe Kaminsky <[EMAIL PROTECTED]>
    Home: 08-9456841

Attachment: pgpUNCcJZXf0C.pgp
Description: PGP signature

Reply via email to