normal exit TERM is not working every time

Bug #924301 reported by Removed by request
8
Affects Status Importance Assigned to Milestone
upstart (Ubuntu)
New
Undecided
Unassigned

Bug Description

I'm using Ubuntu 12.04 dev with upstart 1.4-0ubuntu4. I have written a script which uses the respawn stanza and TERM as a normal exit. But on some commands the process will respawn and on other commands not (like expected) if I use a SIGTERM on the process. Here are 2 examples:

normal exit 0 KILL TERM
respawn
respawn limit 2 60
exec sleep 60

A SIGTERM on the "sleep 60" process will not cause it to respawn.

normal exit 0 KILL TERM
respawn
respawn limit 2 60
exec java -jar /usr/local/bin/minecraft_server.jar nogui

A SIGTERM on the java process will cause it to respawn. I don't know why it is respawning. It is the only process that is created and a SIGTERM shouldn't cause it to respawn.

Revision history for this message
Steve Langasek (vorlon) wrote :

If a job marked 'normal TERM' is respawning when you send it kill -TERM, then the process is probably *not* dying as a result of the signal - it probably instead has a signal handler and is exiting with some different exit status.

There's no other reason why upstart would treat TERM differently for some jobs than others.

Try running the command from the command line, killing it with SIGTERM, and checking what you actually get as an exit status.

Changed in upstart (Ubuntu):
status: New → Invalid
Revision history for this message
Removed by request (removed3425744) wrote :

>If a job marked 'normal TERM' is respawning when you send it kill -TERM, then the process is probably *not* dying as a result of the signal - it probably instead has a signal handler and is exiting with some different exit status.

Shouldn't upstart ignore such a behaviour of a signal handler? The application got still a SIGTERM independent of what it returns.

>Try running the command from the command line, killing it with SIGTERM, and checking what you actually get as an exit status.

"sleep 60" and "java -jar /usr/local/bin/minecraft_server.jar nogui" are returning 143 if they close because of a SIGTERM. I have tried this with test.conf:

normal exit 143
respawn
respawn limit 2 60
exec sleep 60

After a SIGTERM sleep 60 is curiously respawning.

normal exit 143
respawn
respawn limit 2 60
exec java -jar /usr/local/bin/minecraft_server.jar nogui

But the java application doesn't respawn anymore as expected if closed with a SIGTERM.

Changed in upstart (Ubuntu):
status: Invalid → New
Revision history for this message
Steve Langasek (vorlon) wrote : Re: [Bug 924301] Re: normal exit TERM is not working every time

On Sat, Feb 04, 2012 at 11:16:25AM -0000, Sworddragon wrote:
> >If a job marked 'normal TERM' is respawning when you send it kill
> > -TERM, then the process is probably *not* dying as a result of the
> > signal - it probably instead has a signal handler and is exiting with
> > some different exit status.

> Shouldn't upstart ignore such a behaviour of a signal handler? The
> application got still a SIGTERM independent of what it returns.

If this is actually the issue, upstart has no means of properly ignoring
such behavior. There is a semantically significant difference in Unix
between "died with SIGTERM" and "received SIGTERM, then exited"; and if this
is actually what's happening, the exit code in the shell *won't* be 143.

> >Try running the command from the command line, killing it with SIGTERM,
> > and checking what you actually get as an exit status.

> "sleep 60" and "java -jar /usr/local/bin/minecraft_server.jar nogui" are
> returning 143 if they close because of a SIGTERM.

Ok, my analysis was wrong then. I'm not sure why upstart's behavior is
different for java - it certainly shouldn't be based on the above.

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
<email address hidden> <email address hidden>

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.