bug-bash
[Top][All Lists]
Advanced

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

jobs -p falsely reports the last background pid


From: Håkon Bugge
Subject: jobs -p falsely reports the last background pid
Date: Wed, 9 Apr 2014 12:43:40 +0200

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu' 
-DCONF_VENDOR='redhat'\
 -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I. 
 -I. -I./include -I./lib  -D_GNU_SOURCE -DRECYCLES_PIDS -DDEFAULT_PATH_VA\
LUE='/usr/local/bin:/usr/bin'  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 
-fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic
uname output: Linux lab07.no.oracle.com 3.11.10-200.fc19.x86_64 #1 SMP Mon Dec 
2 20:28:03 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-redhat-linux-gnu

Bash Version: 4.2
Patch Level: 45
Release Status: release

Description:
This script never terminates:
--------------------------------------------------
#!/bin/bash 

for P in `seq 5`; do 
    sleep 1&
done

while true; do
    usleep 20000
    set foo `jobs -p`
    LEFT=$#
    LEFT=$[LEFT-1]
    echo $LEFT jobs left
    if [ x$LEFT = x0 ]; then
        break
    fi
done
-------------------------------------------------

Repeat-By:
    Assume the above scripts is named bug.sh, simply execute:

./bug.sh


Fix:
   Pasting the same commands in an interactive shell, its works.




reply via email to

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