bug-bash
[Top][All Lists]
Advanced

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

Re: jobs -p falsely reports the last background pid


From: Greg Wooledge
Subject: Re: jobs -p falsely reports the last background pid
Date: Wed, 9 Apr 2014 08:28:09 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Apr 09, 2014 at 02:16:22PM +0200, Håkon Bugge wrote:
> That is not the issue. Try it out.

Very well.  I can confirm that this script does not terminate on HP-UX
10.20 under bash 4.3.8:

#!/bin/bash
set -m
for x in 1 2 3 4 5; do sleep 1 & done
while jobs=$(jobs -p)
      echo "jobs left: <$jobs>"
      [[ $jobs != "" ]]
do
    sleep 1
done

As a workaround, you could consider using "wait" instead of this polling
loop to detect the termination of child processes.  This script, for
example, properly waits and terminates:

#!/bin/bash
set -m
for x in 1 2 3 4 5; do sleep 1 & done
wait



reply via email to

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