Gentoo Archives: gentoo-user

From: Moshe Kaminsky <kaminsky@××××××××××××.il>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: [OT] kill a child and suicide
Date: Thu, 04 May 2006 16:16:41
Message-Id: 20060504155527.GA25794@kaminsky
In Reply to: Re: [gentoo-user] Re: [OT] kill a child and suicide by Jorge Almeida
1 * Jorge Almeida <jalmeida@××××××××××××.pt> [03/05/06 23:30]:
2 > On Wed, 3 May 2006, Moshe Kaminsky wrote:
3 >
4 > >* Jorge Almeida <jalmeida@××××××××××××.pt> [03/05/06 19:30]:
5 > >>On Wed, 3 May 2006, Moshe Kaminsky wrote:
6 > >>
7 > >>>You can use 'kill 0' to send a signal to your own process group.
8 > >>>Something like this:
9 > >>>
10 > >>>#!/bin/sh
11 > >>>trap 'kill 0;exit' TERM
12 > >>>echo "before"
13 > >>>( sleep 30; echo inside )
14 > >>>echo "after"
15 > >>>
16 > >>No use. trap will wait till the running child is completed, which is not
17 > >>what
18 > >>I want (as reply of Hans-Werner).
19 > >
20 > >Well, I just tried it, and it worked.
21 > >
22 > You mean the parent received the TERM signal while sleep'ing 30 and the
23 > child terminated before the 30 seconds were through?
24 > I intend to use the script with a long rsync, which must terminate when
25 > receiving the signal.
26 > I tested your script with 3000 instead of 30, and the script outputs
27 > "after" and terminates when I send it a TERM; however, a process "sleep
28 > 3000" still comes out in the output of ps auxf (as an orphan), I had to
29 > kill it explicitly.
30
31 Funny, I just tried the same, and it worked. It also didn't print any
32 "after" (appropriately, since the sig handler includes 'exit'), and I
33 didn't find any sleep process. Maybe it was from some different
34 experiment?
35
36 Moshe
37
38 >
39 > Jorge
40 > --
41 > gentoo-user@g.o mailing list
42 >
43
44 --
45 I love deadlines. I like the whooshing sound they make as they fly by.
46 -- Douglas Adams
47
48 Moshe Kaminsky <kaminsky@××××××××××××.il>
49 Home: 08-9456841

Replies

Subject Author
Re: [gentoo-user] Re: [OT] kill a child and suicide Hans-Werner Hilse <hilse@×××.de>
Re: [gentoo-user] Re: [OT] kill a child and suicide Willie Wong <wwong@×××××××××.EDU>
Re: [gentoo-user] Re: [OT] kill a child and suicide Jorge Almeida <jalmeida@××××××××××××.pt>