On Sun, Jan 23, 2011 at 10:06:40PM +0800, jida...@jidanni.org wrote: > Gentlemen, I am disturbed by these seemingly irregular results, > # perl -pwle 's/\d{4}/0000/' mm|sort|uniq -c > 88 ++ kill 0000
Huh? Speak clearly. > from running my program > # cat rt > set -x > set -m > sleep 33& > kill $! > set +m > sleep 44& > kill $! etc. > We see some of the sleeps are reported some of the time, and on what > line something was terminated differs too. Also didn't I run it 22 > times? Why do some things show up only a couple times instead of all or > none? Eh? What's the question? Subject: Re: set -m +m -x and the element of chance or is it race conditions? Is that the question? What are you trying to do, exactly? Are you trying to run a script with job control enabled but silence the shell's reporting of terminated jobs? If so, then yes, you're probably looking at a race condition here. You're flipping -m on and off so quickly that I don't know what you're expecting to see. If you want to silence the "job xxx killed" messages produced by the shell with job control on, then what you need to do is redirect the shell's stderr before the kill, and for a reasonable period of time afterward, to allow time for the signal to be received and acted upon, and for the shell to (not) report the job's demise. A much easier way, of course, is simply not to enable job control at all. Then the shell won't report on child process deaths. If you're NOT trying to silence job control's reporting, then please present the question more clearly. English is easier for us to read than mysterious perl output.