Here's a job control conundrum for you.

Steven W. Orr steveo at syslang.net
Wed Apr 11 15:13:59 EDT 2007


On Wednesday, Apr 11th 2007 at 14:17 -0400, quoth Ben Scott:

=>On 4/11/07, Steven W. Orr <steveo at syslang.net> wrote:
=>> BTW, it turns out that killall -1 alpine from another window *is*
=>> effective.
=>
=> That almost sounds like killall is refusing to send the signal to
=>your process group as a "safety measure" kind of thing, i.e., don't
=>let the user kill himself.  The thing is, I've killed myself with
=>killall before, so that's not consistent.  Hrmmmm.
=>
=>> The --verbose shows that the kill(2) call did in fact not fail and that
=>> the process was delivered.
=>
=> So much for that theory.
=>
=> Hmmm, one correction, though: That shows the signal was *sent*.  You
=>need to use "--wait" to have killall wait and tell you if/when the
=>signal was *received*.

--wait doesn't return if the signal is received. There's no delay between 
the send and receive of a signal. --wait will loop around looking to see 
if the process actually disappears. The exit status of kill(2) is the 
indicator of whethr the signal was delivered.

=>
=>[various interesting commands]
=>> The fg then only prints out the name of the process but nothing happens.
=>
=> Hmmm.  Maybe a process cannot receive a signal when it is stopped?
=>I seem to recall that's the behavior.  You have to wake it up, then
=>the signals get delivered.  So when killall sends SIGHUP or SIGKILL,
=>the process doesn't get it until you wake it up, at which point it
=>gets delivered, and "alpine" promptly complies by exiting.

This is why I think it may be a bug in alpine. signal(2) can only handle 
one signal at a time. sigaction(2) will allow signals to stack up.

=> So why does "kill -1" work?  Well, kill is a shell built-in.  Maybe
=>it is aware of job status in your shell, and "helps" you by sending
=>SIGCONT to wake it up.

Naaa ;-)

=> Of course, this doesn't explain why a different shell's invocation
=>does work.  But I think this might be an avenue of exploration worth
=>following for a bit.  So, what happens if, instead of using the
=>shell's built-in kill, you do:
=>
=>	/bin/kill -1 $PID_OF_ALPINE

It's a mystery... ;-)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


More information about the gnhlug-discuss mailing list