Gentoo Archives: gentoo-user

From: Etaoin Shrdlu <shrdlu@×××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] kill a child and suicide
Date: Tue, 02 May 2006 13:17:44
Message-Id: 200605021524.50009.shrdlu@unlimitedmail.org
In Reply to: [gentoo-user] [OT] kill a child and suicide by Jorge Almeida
1 On Tuesday 02 May 2006 14:40, Jorge Almeida wrote:
2
3 > parent.sh
4 > #!/bin/bash
5 > <do something>
6 > /path/to/child.sh
7 > <do something else>
8 >
9 > When parent.sh receives a TERM signal, I would like child.sh to
10 > receive TERM also, and then parent.sh receive TERM.
11 > The <do something else> part is why I can't use "exec
12 > /path/to/child.sh". Is there some way to achieve this?
13
14 I think (untested) you can do something like
15
16 trap 'kill <pid of child>' TERM
17
18 at then beginning of parent.sh. This way, when the parent recives TERM it
19 in turn sends a TERM to the child. If you want the parent to terminate,
20 add the exit command as well:
21
22 trap 'kill <pid of child>; exit 1' TERM
23
24 (don't know how the parent can wait for termination of child, but it
25 should be possible I think)
26
27 "man trap" gives you the details.
28 --
29 gentoo-user@g.o mailing list

Replies

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