1 |
* Jorge Almeida <jalmeida@××××××××××××.pt> [02/05/06 16:00]: |
2 |
> parent.sh |
3 |
> #!/bin/bash |
4 |
> <do something> |
5 |
> /path/to/child.sh |
6 |
> <do something else> |
7 |
> |
8 |
> When parent.sh receives a TERM signal, I would like child.sh to receive |
9 |
> TERM also, and then parent.sh receive TERM. |
10 |
> The <do something else> part is why I can't use "exec /path/to/child.sh". Is |
11 |
> there some way to achieve this? |
12 |
|
13 |
You can use 'kill 0' to send a signal to your own process group. |
14 |
Something like this: |
15 |
|
16 |
#!/bin/sh |
17 |
trap 'kill 0;exit' TERM |
18 |
echo "before" |
19 |
( sleep 30; echo inside ) |
20 |
echo "after" |
21 |
|
22 |
Note that you can also send the signal with the negative of the pid, and |
23 |
then it goes to the whole process group. |
24 |
|
25 |
Moshe |
26 |
|
27 |
> |
28 |
> -- |
29 |
> Jorge Almeida |
30 |
> -- |
31 |
> gentoo-user@g.o mailing list |
32 |
> |
33 |
|
34 |
-- |
35 |
I love deadlines. I like the whooshing sound they make as they fly by. |
36 |
-- Douglas Adams |
37 |
|
38 |
Moshe Kaminsky <kaminsky@××××××××××××.il> |
39 |
Home: 08-9456841 |