On Thu, May 04, 2006 at 06:55:28PM +0300, Penguin Lover Moshe Kaminsky squawked:
> Funny, I just tried the same, and it worked. It also didn't print any 
> "after" (appropriately, since the sig handler includes 'exit'), and I 
> didn't find any sleep process. Maybe it was from some different 
> experiment?
> 

How did you try actually? I got curious so I took a look myself. 

Here's what I did:

I ran
  [01:25 PM]wwong ~ $ bash -c "trap 'kill 0;exit' TERM; echo before; ( sleep 
45; echo inside ) ; echo after"
in a bash session. Associated with it, of course, are two bash processes (the 
one 
that executes the entire statement and the one that runs the bits inside the 
parenthesis (a subshell)) and a sleep process

(trimmed output from 'ps auxf')
21226 ?      /usr/bin/rxvt -rv
26580 pts/1   \_ bash
24292 pts/1       \_ bash -c trap 'kill 0;exit' TERM; echo before; ( sleep 45; 
echo inside ) ;
22743 pts/1           \_ bash -c trap 'kill 0;exit' TERM; echo before; ( sleep 
45; echo inside
13126 pts/1               \_ sleep 45

Now, I send SIGTERM to the various processes:

if I send 'kill -15 13126', as expected, the sleep process would exit, bash 
would
complain that the process terminated, it would display 
  before
  [bash complaint]
  inside
  after
if I send 'kill -15 22743', the bash process that does the sleeping part would 
terminate, leaving an orphaned 'sleep' process. The output on the initial 
terminal would be
  before
  after
if I send 'kill -15 24292', the process doesn't react at first. It would exit 
after
the 22743 process completed. So it would display 'before', wait 45 seconds, and 
then display 'inside' and then stops. 

W
-- 
I cannot go to school today"  
Said little Peggy Ann McKay.
"I have the measles and the mumps,   
A gash, a rash and purple bumps.
My mouth is wet, my throat is dry.
I'm going blind in my right eye.  
My tonsils are as big as rocks,
I've counted sixteen chicken pox
And there's one more-that's seventeen,
And don't you think my face looks green?
My leg is cut, my eyes are blue 
It might be instamatic flu.
I cough and sneeze and gasp and choke,
I'm sure that my left leg is broke
My hip hurts when I move my chin,
My belly button's caving in,
My back is wrenched, my ankle's sprained,
My 'pendix pains each time it rains.
My toes is cold, my toes are numb,
I have a sliver in my thumb.
My neck is stiff, my voice is weak,
I hardly whisper when I speak.
My tongue is filling up my mouth,
I think my hair is falling out.      
My elbow's bent, my spine ain't straight,
My temperature is one-o-eight.
My brain is shrunk, I cannot hear,
There's a hole inside my ear.  
I have a hangnail, and my heart is - What?
What's that? What's that you say?
You say today is .......Saturday?
Goodbye, I'm going out to play!"
Sortir en Pantoufles: up 173 days,  9:53
-- 
gentoo-user@gentoo.org mailing list

Reply via email to