Bash loses track of background children sometimes

Bug #828895 reported by Ben Harris
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Under some circumstances (I've not worked out precisely what), bash can forget about background child processes. For instance, if the file "simpletest" contains:

#! /bin/bash

count=0

while [ $count -lt 51 ]; do
    count=$((count+1))
    /nonexist
    true &
    bgpids="$bgpids $!"
done

for pid in $bgpids; do
    wait $pid
done

then running "bash simpletest", seems to reliably report "simpletest: line 13: wait: pid 28850 is not a child of this shell" (with different PIDs each time, obviously). Increasing the "51" in the script increases the number of errors. Curiously, removing the call to a nonexistent program causes the problem to stop manifesting.

"getconf CHILD_MAX" returns "undefined", which I think means that Bash should support an unlimited number of unwaited children.

I've observed this on two different amd64 boxes running Ubuntu 10.04 LTS, and it persisted after I upgraded the bash package to 4.2-0ubuntu4. I couldn't reproduce it on an i386 box running Ubuntu 11.04.

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: bash 4.1-2ubuntu3
ProcVersionSignature: Ubuntu 2.6.32-33.72-server 2.6.32.41+drm33.18
Uname: Linux 2.6.32-33-server x86_64
Architecture: amd64
Date: Thu Aug 18 17:04:23 2011
InstallationMedia: Ubuntu-Server 10.04.3 LTS "Lucid Lynx" - Release amd64 (20110719.2)
ProcEnviron:
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
SourcePackage: bash

Revision history for this message
Ben Harris (bjh21) wrote :
Revision history for this message
Timothy Mayoh (timothy-m-deactivatedaccount) wrote :

I can confirm this also occurs on Ubuntu 11.04 AMD64.

Changed in bash (Ubuntu):
status: New → Confirmed
Revision history for this message
Ben Harris (bjh21) wrote :

Just a quick note: having moved some affected systems back to Ubuntu, this bug has just manifested in production on Ubuntu 16.04 LTS:

/opt/dump/bin/dump_multi: line 11: wait: pid 56652 is not a child of this shell

My test script above no longer demonstrates it though. I'll see if I can come up with one that does.

Ken Sharp (kennybobs)
tags: added: xenial
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.