Gentoo Archives: gentoo-user

From: Zac Slade <krakrjak@××××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] kill a child and suicide
Date: Tue, 02 May 2006 16:33:21
Message-Id: 200605021125.47410.krakrjak@volumehost.net
In Reply to: Re: [gentoo-user] [OT] kill a child and suicide by Jorge Almeida
1 On Tuesday 02 May 2006 08:48, Jorge Almeida wrote:
2 > On Tue, 2 May 2006, Etaoin Shrdlu wrote:
3 > > I think (untested) you can do something like
4 > >
5 > > trap 'kill <pid of child>' TERM
6 > >
7 > > at then beginning of parent.sh. This way, when the parent recives TERM it
8 > > in turn sends a TERM to the child. If you want the parent to terminate,
9 > > add the exit command as well:
10 > >
11 > > trap 'kill <pid of child>; exit 1' TERM
12 >
13 > But how to find out the PID of child? What would be convenient is a way
14 > to send signals "recursively" to a process and its children.
15 > Maybe I'm trying to solve a problem with wrong tools...
16 > Thanks,
17 You can find the PID of the last backgrouned process using the bash variable
18 $!
19
20 So something like:
21 subprocess &
22 $pid=$!
23
24 Using trap along with maybe setting alarms should get you what you want.
25 --
26 Zac Slade
27 krakrjak@××××××××××.net
28 ICQ:1415282 YM:krakrjak AIM:ttyp99
29 --
30 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] [OT] kill a child and suicide Jorge Almeida <jalmeida@××××××××××××.pt>