10

What signal will upstart/initctl use to restart a job? Furthermore, is there any way to specify that SIGHUP should be used?

Alternately, is there a way to define a custom reload command that will send a SIGHUP? Or do I need to go outside of upstart to do that?

David Eyk
  • 667
  • 1
  • 7
  • 17

1 Answers1

23

What signal will upstart/initctl use to restart a job?

SIGTERM

$ strace -fp `pgrep cron` 2> ~/strace &
$ initctl restart cron
$ cat ~/strace
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {0x804a280, [CHLD], SA_RESTART}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({60, 0}, {57, 153662204})     = ? ERESTART_RESTARTBLOCK (To be restarted)
--- SIGTERM (Terminated) @ 0 (0) ---
Process 2275 detached

Furthermore, is there any way to specify that SIGHUP should be used?

Use: initctl reload

Alternately, is there a way to define a custom reload command that will send a SIGHUP?

Use: initctl reload

Or do I need to go outside of upstart to do that?

Use initctl reload or kill/killall -HUP

dimo414
  • 376
  • 1
  • 3
  • 16
bindbn
  • 5,153
  • 2
  • 26
  • 23
  • Very thorough. Thank you. Guess I could have found some of that on the man page! – David Eyk Oct 11 '10 at 16:32
  • It's upgraded to a SIGKILL if the service doesn't stop in time. "Stopping a job involves sending SIGTERM to it. ... However, if the service takes more than kill timeout seconds (default, 5 seconds) then it will be sent SIGKILL" http://upstart.ubuntu.com/cookbook/#pre-stop – scipilot Aug 11 '17 at 00:54