bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

set -m +m -x and the element of chance or is it race conditions?


From: jidanni
Subject: set -m +m -x and the element of chance or is it race conditions?
Date: Sun, 23 Jan 2011 22:06:40 +0800
User-agent: Mutt/1.5.13 (2006-08-11)

Gentlemen, I am disturbed by these seemingly irregular results,
# perl -pwle 's/\d{4}/0000/' mm|sort|uniq -c
     88 ++ kill 0000
     44 ++ set +m
     44 ++ set -m
      1 ++ sleep 33
      2 ++ sleep 66
      1 ./rt: line 12:  0000 Terminated              sleep 33
      1 ./rt: line 12:  0000 Terminated              sleep 44
      1 ./rt: line 13:  0000 Terminated              sleep 33
      1 ./rt: line 13:  0000 Terminated              sleep 44
      1 ./rt: line 13:  0000 Terminated              sleep 55
      3 ./rt: line 14:  0000 Terminated              sleep 33
      3 ./rt: line 14:  0000 Terminated              sleep 44
      3 ./rt: line 14:  0000 Terminated              sleep 55
from running my program
# cat rt
set -x
set -m
sleep 33&
kill $!
set +m
sleep 44&
kill $!
sleep 55&
set -m
kill $!
sleep 66&
set +m
kill $!
# for i in `seq 22`; do ./rt; done 2> mm

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?

P.S., on the man page

              -m      Monitor mode. Job control is enabled. This option is on
                      by default for interactive shells on systems that
                      support it (see JOB CONTROL above). Background
                      processes run in a separate process group and a
                      line containing their exit status is printed upon
                      their completion.

Perhaps mention if what happens if this is turned on or off after
starting the job but before its completion.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]