Gentoo Archives: gentoo-user

From: Jorge Almeida <jalmeida@××××××××××××.pt>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: [OT] kill a child and suicide
Date: Wed, 03 May 2006 20:00:21
Message-Id: Pine.LNX.4.64.0605032001130.27711@jmaa.math.ist.utl.pt
In Reply to: [gentoo-user] Re: [OT] kill a child and suicide by Moshe Kaminsky
1 On Wed, 3 May 2006, Moshe Kaminsky wrote:
2
3 > * Jorge Almeida <jalmeida@××××××××××××.pt> [03/05/06 19:30]:
4 >> On Wed, 3 May 2006, Moshe Kaminsky wrote:
5 >>
6 >>> You can use 'kill 0' to send a signal to your own process group.
7 >>> Something like this:
8 >>>
9 >>> #!/bin/sh
10 >>> trap 'kill 0;exit' TERM
11 >>> echo "before"
12 >>> ( sleep 30; echo inside )
13 >>> echo "after"
14 >>>
15 >> No use. trap will wait till the running child is completed, which is not what
16 >> I want (as reply of Hans-Werner).
17 >
18 > Well, I just tried it, and it worked.
19 >
20 You mean the parent received the TERM signal while sleep'ing 30 and the
21 child terminated before the 30 seconds were through?
22 I intend to use the script with a long rsync, which must terminate when
23 receiving the signal.
24 I tested your script with 3000 instead of 30, and the script outputs
25 "after" and terminates when I send it a TERM; however, a process "sleep
26 3000" still comes out in the output of ps auxf (as an orphan), I had to
27 kill it explicitly.
28
29 Jorge
30 --
31 gentoo-user@g.o mailing list

Replies

Subject Author
[gentoo-user] Re: [OT] kill a child and suicide Moshe Kaminsky <kaminsky@××××××××××××.il>