bug-bash
[Top][All Lists]
Advanced

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

Race condition determining value of $? variable


From: Марк Коренберг
Subject: Race condition determining value of $? variable
Date: Mon, 26 Feb 2007 16:49:16 +0500

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include
-I./lib -D_GNU_SOURCE  -O2 -march=i386 -mcpu=i686 -g
uname output: Linux server-testvpn 2.4.24 #33 SMP юФЧ жЕЧ 22 10:05:53
MSK 2007 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:
   Race condition, appeared when background job completed in moment
   between ending of foregroung program and calculating value of $? variable

Repeat-By:
   set -m
   exec 4>/dev/null
   while true; do
     usleep $((RANDOM*30)) >&4 2>&1 &
     output=$( /bin/false )
     #when sigchild appear here, become race condition ;-)
     # and return value of usleep is placed to $?
     # what was also tested:
     # 1. manually written usleep which always return code 22 after sleeping
     #    tmp=$?; [ "$tmp" = 0 ] || continue ; echo $tmp => show 22
in the output
     # 2. output=$( exec /bin/false ) - triggers race condition
     # 3. output=`/bin/false` - trigger rage condition
     # 4. /bin/false - NOT TRIGGERS
     # 5. ( /bin/false ) - NOT TRIGGERS
     [ "$?" = 0 ] || continue
     echo "YEP! race condition catched!"
     break;
   done

reply via email to

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