Gentoo Archives: gentoo-user

From: Willie Wong <wwong@×××××××××.EDU>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: [OT] kill a child and suicide
Date: Thu, 04 May 2006 18:19:04
Message-Id: 20060504175759.GA13319@princeton.edu
In Reply to: [gentoo-user] Re: [OT] kill a child and suicide by Moshe Kaminsky
1 On Thu, May 04, 2006 at 06:55:28PM +0300, Penguin Lover Moshe Kaminsky squawked:
2 > Funny, I just tried the same, and it worked. It also didn't print any
3 > "after" (appropriately, since the sig handler includes 'exit'), and I
4 > didn't find any sleep process. Maybe it was from some different
5 > experiment?
6 >
7
8 How did you try actually? I got curious so I took a look myself.
9
10 Here's what I did:
11
12 I ran
13 [01:25 PM]wwong ~ $ bash -c "trap 'kill 0;exit' TERM; echo before; ( sleep 45; echo inside ) ; echo after"
14 in a bash session. Associated with it, of course, are two bash processes (the one
15 that executes the entire statement and the one that runs the bits inside the
16 parenthesis (a subshell)) and a sleep process
17
18 (trimmed output from 'ps auxf')
19 21226 ? /usr/bin/rxvt -rv
20 26580 pts/1 \_ bash
21 24292 pts/1 \_ bash -c trap 'kill 0;exit' TERM; echo before; ( sleep 45; echo inside ) ;
22 22743 pts/1 \_ bash -c trap 'kill 0;exit' TERM; echo before; ( sleep 45; echo inside
23 13126 pts/1 \_ sleep 45
24
25 Now, I send SIGTERM to the various processes:
26
27 if I send 'kill -15 13126', as expected, the sleep process would exit, bash would
28 complain that the process terminated, it would display
29 before
30 [bash complaint]
31 inside
32 after
33 if I send 'kill -15 22743', the bash process that does the sleeping part would
34 terminate, leaving an orphaned 'sleep' process. The output on the initial
35 terminal would be
36 before
37 after
38 if I send 'kill -15 24292', the process doesn't react at first. It would exit after
39 the 22743 process completed. So it would display 'before', wait 45 seconds, and
40 then display 'inside' and then stops.
41
42 W
43 --
44 I cannot go to school today"
45 Said little Peggy Ann McKay.
46 "I have the measles and the mumps,
47 A gash, a rash and purple bumps.
48 My mouth is wet, my throat is dry.
49 I'm going blind in my right eye.
50 My tonsils are as big as rocks,
51 I've counted sixteen chicken pox
52 And there's one more-that's seventeen,
53 And don't you think my face looks green?
54 My leg is cut, my eyes are blue
55 It might be instamatic flu.
56 I cough and sneeze and gasp and choke,
57 I'm sure that my left leg is broke
58 My hip hurts when I move my chin,
59 My belly button's caving in,
60 My back is wrenched, my ankle's sprained,
61 My 'pendix pains each time it rains.
62 My toes is cold, my toes are numb,
63 I have a sliver in my thumb.
64 My neck is stiff, my voice is weak,
65 I hardly whisper when I speak.
66 My tongue is filling up my mouth,
67 I think my hair is falling out.
68 My elbow's bent, my spine ain't straight,
69 My temperature is one-o-eight.
70 My brain is shrunk, I cannot hear,
71 There's a hole inside my ear.
72 I have a hangnail, and my heart is - What?
73 What's that? What's that you say?
74 You say today is .......Saturday?
75 Goodbye, I'm going out to play!"
76 Sortir en Pantoufles: up 173 days, 9:53
77 --
78 gentoo-user@g.o mailing list