bug-bash
[Top][All Lists]
Advanced

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

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


From: Greg Wooledge
Subject: Re: set -m +m -x and the element of chance or is it race conditions?
Date: Mon, 24 Jan 2011 10:18:52 -0500
User-agent: Mutt/1.4.2.3i

On Mon, Jan 24, 2011 at 10:46:03PM +0800, jidanni@jidanni.org wrote:
> Thanks Greg, but aren't I acting by the rules?

I don't know.  I've never before seen anyone flip monitor mode on and off
like a toddler that just discovered a light switch.

imadev:~$ cat normal
#!/bin/sh
sleep 20 &
kill $!

imadev:~$ for i in {1..10}; do ./normal; done
 
(no output)


imadev:~$ cat abnormal
#!/usr/local/bin/bash-4.1.9
sleep 20 &
kill $!

imadev:~$ for i in {1..10}; do ./abnormal; done
./abnormal: line 4: 11164 Terminated              sleep 20
./abnormal: line 4: 11166 Terminated              sleep 20
./abnormal: line 4: 11168 Terminated              sleep 20
./abnormal: line 4: 11170 Terminated              sleep 20
./abnormal: line 4: 11172 Terminated              sleep 20
./abnormal: line 4: 11174 Terminated              sleep 20
./abnormal: line 4: 11176 Terminated              sleep 20
./abnormal: line 4: 11178 Terminated              sleep 20
./abnormal: line 4: 11180 Terminated              sleep 20
./abnormal: line 4: 11182 Terminated              sleep 20

*shrug* Even without screwing around with monitor mode, bash just loves
to report these for me.  sh does not.  I can't even reproduce your results.

> $ cat l
> set +m
> sleep 44&
> kill $!
> $ for i in `seq 33`; do bash -xm l; done
> 
> Which gives
> + kill 5256
> + set +m
> + kill 5258
> + set +m
> + kill 5260
> l: line 4:  5260 Terminated              sleep 44
> + set +m
> + kill 5262
> + set +m
> + kill 5264
> + set +m
> I.e., one out of the 33 cases produced the Terminated message on my one
> test run.

I get:

imadev:~$ cat jidanni
set +m
sleep 44&
kill $!

imadev:~$ for i in {1..10}; do bash -xm jidanni; done
+ set +m
+ sleep 44
+ kill 11226
jidanni: line 4: 11226 Terminated              sleep 44
+ set +m
+ sleep 44
+ kill 11228
jidanni: line 4: 11228 Terminated              sleep 44
+ set +m
+ sleep 44
+ kill 11230
jidanni: line 4: 11230 Terminated              sleep 44
+ set +m
+ sleep 44
+ kill 11232
jidanni: line 4: 11232 Terminated              sleep 44
+ set +m
+ sleep 44
+ kill 11234
jidanni: line 4: 11234 Terminated              sleep 44
+ set +m
+ sleep 44
+ kill 11236
jidanni: line 4: 11236 Terminated              sleep 44
+ set +m
+ sleep 44
+ kill 11238
jidanni: line 4: 11238 Terminated              sleep 44
+ set +m
+ sleep 44
+ kill 11240
jidanni: line 4: 11240 Terminated              sleep 44
+ set +m
+ sleep 44
+ kill 11242
jidanni: line 4: 11242 Terminated              sleep 44
+ set +m
+ sleep 44
+ kill 11244
jidanni: line 4: 11244 Terminated              sleep 44

I get the same thing regardless of which version of bash is used, or the
presence or absence of "set +m" inside, or "-m" on invocation... none
of it seems to matter.

You used seq, so you're clearly doing it on Linux.  Maybe it's an
OS-specific thing?



reply via email to

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