Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14809

Strange behaviour from jobs -p in a subshell

From Christopher Jefferson <caj21@st-andrews.ac.uk>
Newsgroups gnu.bash.bug
Subject Strange behaviour from jobs -p in a subshell
Date 2018-11-13 09:28 +0000
Message-ID <mailman.3977.1542119200.1284.bug-bash@gnu.org> (permalink)

Show all headers | View raw


Consider the following script. While the 3 sleeps are running, both jobs 
-p and $(jobs -p) will print 3 PIDs. Once the 3 children are finished, 
jobs -p will continue to print the 3 PIDs of the done Children, but 
$(jobs -p) will only print 1 PID. $(jobs -p) always seems to print at 
most 1 PID of a done child.


#!/usr/bin/bash

(sleep 2 ) &
(sleep 2 ) &
(sleep 2 ) &

while /bin/true
do
     echo A
     echo $(jobs -p)
     echo B
     jobs -p
     echo C
     sleep 1
done

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Strange behaviour from jobs -p in a subshell Christopher Jefferson <caj21@st-andrews.ac.uk> - 2018-11-13 09:28 +0000

csiph-web