[Bug 406397] Re: init: job stuck with expect fork/daemon when parent reaps child

Wade Fitzpatrick wade at waddles.org
Fri Mar 15 01:44:42 CET 2013


I had a problem with john miller's bash script because bash didn't die
quickly enough for the microsleep to get re-parented by init (upstart),
so here is a better version:

#!/bin/bash

usleep 1 &
firstPID=$!
#first lets exhaust the space
while (( $! >= $firstPID ))
do
    usleep 1 &
done

# [ will use testPID itself, we want to use the next pid
declare -i testPID
testPID=$(($1 - 1))
while (( $! < $testPID ))
do
    usleep 1 &
done

# fork a background process then die so init reaps its pid
sleep 3 &
echo "Init will reap PID=$!"
kill -9 $$
# EOF

Example usage:
# sh /tmp/upstart_fix.sh 19915
Init will reap PID=19915
Killed

-- 
You received this bug notification because you are subscribed to PLD
Linux.
https://bugs.launchpad.net/bugs/406397

Title:
  init: job stuck with expect fork/daemon when parent reaps child

Status in Upstart:
  Triaged
Status in “upstart” package in Ubuntu:
  Invalid
Status in “upstart” package in Debian:
  Confirmed
Status in PLD Linux Distribution:
  New

Bug description:
  Hi

  Wrong use of the expect fork stanza can create job with status
    job stop/killled, process nnn
  without any process nnn running on the system.

  As an example the following avahi.conf should have used
  "expect daemon", but will instead create a stuck job.

  stop on stopping dbus-system
  respawn
  expect fork
  exec avahi-daemon -D

  /Emil Renner Berthing

To manage notifications about this bug go to:
https://bugs.launchpad.net/upstart/+bug/406397/+subscriptions


More information about the pld-bugs mailing list