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

john miller johnmille1 at gmail.com
Fri Aug 31 16:12:55 CEST 2012


I came up with a hack to use upstart with applications that fork more
than twice to use until the rewrite makes it downstream. It works for my
application on my system. YMMV.

1.    start the application in the pre-start section
2.    in the script section run a script that runs as long as the application runs. The pid of this script is what upstart will track.
3.    in the post-stop section kill the application

example

env DAEMON=/usr/bin/forky-application

pre-start script
    su -s /bin/sh -c "$DAEMON" joeuseraccount
end script

script 
    sleepWhileAppIsUp(){
        while pidof $1 >/dev/null; do
            sleep 1
        done
    }

    sleepWhileAppIsUp $DAEMON
end script

post-stop script
    if pidof $DAEMON;
    then
        kill `pidof $DAEMON`
        #pkill  $DAEMON # post-stop process (19300) terminated with status 1
    fi
end script

a similar approach could be taken with pid files.

-- 
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:
  New
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