Upstart job's process getting killall-ed on reboot

James Hunt james.hunt at canonical.com
Mon Apr 4 10:31:34 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/04/11 19:40, Loïc Minier wrote:
>         Hi
> 
>  In Linaro, we were using a /etc/init/openvt.conf job like:
> 
> start on started tty1
> 
> respawn
> pre-start script
>   if status tty1 | grep -q start/; then
>     stop tty1
>   fi
> end script
> exec /bin/openvt -e -c 1 -f -- /bin/auto-root-login
> 
>  On shutdown I would get:
> * Killing all remaining processes...
> init: openvt main process ended, respawning
> 
>  Steve Langasek tells me that this should not happen because processes
>  associated with upstart jobs are supposed to be excluded from the
>  killall at shutdown.
Hi Loïc,

Steve is correct, but the handling of processes at shutdown is somewhat
delicate and complicated by the fact that:

- - Upstart never shuts down itself
- - Upstart never stops job with no "stop on"
- - Upstart can respawn killed jobs
- - Ubuntu employs both Upstart and SysV jobs

The main problem here is that although /etc/init.d/sendsigs kills
processes at shutdown on Ubuntu, it is racy since it queries running
Upstart jobs and then kills the associated PIDS. However, that 2-stage
operation is not atomic. Added to which, if a job -- such as openvt --
specifies "respawn", killing the PID associated with it won't
necessarily help since Upstart will respawn the job (although note
"respawn limit" in man 5 init). A short-term solution I think would be
to change /etc/init.d/sendsigs so that it manually stops all jobs with
no "stop on" condition. This will stop Upstart from respawning them. See:


http://upstart.ubuntu.com/cookbook/#list-all-jobs-with-no-stop-on-condition

I've raised a bug for this:

  https://bugs.launchpad.net/ubuntu/+source/sysvinit/+bug/750141

A better solution would appear to be some way to stop Upstart respawning
any more jobs. Maybe a new initctl command such as "initctl
disable-spawn" could be introduced to allow existing jobs to finish, but
disallow any new jobs or respawns to occur? I've created a bug for this
so we can consider it for Oneiric:

  https://bugs.launchpad.net/upstart/+bug/750113

> I worked around it by adding this to the job:
> stop on runlevel [!2345]
That seems fine for the openvt job.

> 
>  Would you confirm whether this is indeed a bug or whether that's normal
>  behavior?
> 
>    Thanks!
Well, I think the main issue is really with the sysvinit package and the
openvt job configuration file. It does beg the question though how a
"pure" Upstart installation (in other words a system with no SysV legacy
support) would/should handle shutdown cleanly. One option of course
would be to create a shutdown.conf that stopped all jobs (ensuring it
stopped itself last of course :-)

Cheers,

James.
- --
James Hunt
____________________________________
Ubuntu Foundations Team, Canonical.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2ZngMACgkQYBWEaHcQG9djaACeOUGd88cj5tOC1LPAj+r/6bpa
iuAAn2qtxcyq1qOQ+RTfxlhvqDmEB/0j
=eVhO
-----END PGP SIGNATURE-----



More information about the upstart-devel mailing list