sendsigs can kill upstart scripts' child processes prematurely on system shutdown
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
sysvinit (Ubuntu) |
Won't Fix
|
Medium
|
Unassigned |
Bug Description
Binary package hint: sysvinit
sendsigs can kill child processes executed as part of upstart pre/post-stop scripts. It successfully omits upstart processes (daemons and the script processes themselves), but if you use anything other than shell builtins in an upstart job script, those shell-spawned processes don't wind up in OMITPIDS and killall5 kills them.
For example, 143 (15/SIGTERM) ends up in /tmp/foo with a script like this.
pre-stop script
sleep 30 || echo $? >/tmp/foo
end script
Also, the post-SIGTERM loop ends prematurely because killall5 supports a maximum of 16 omitted processes (LP#634460). In my case, the ssh (LP#603363), portmap, statd, and (obviously) rc upstart jobs are still running. Each iteration of the post-SIGTERM loop duplicates these processes in OMITPIDS. On the fifth iteration, the list overflows and killall5 terminates with exitstatus 1. The loop terminates prematurely, since it interprets killall5 failure as an indicator that all SIGTERMed processes have terminated.
The attached sendsigs fixes both problems. It won't kill processes that are children of upstart processes. In doing so, it avoids the use of killall5(1), allowing SIGTERMed processes the full ten seconds to shut down gracefully before SIGKILL. If killall5 had parent process checking, using that would be faster, but the fixed omitpid list size would still be a problem. Doing it "by hand" in the shell is reasonably fast, since there shouldn't be many processes still running.
Changed in sysvinit (Ubuntu): | |
status: | New → Confirmed |
Changed in sysvinit (Ubuntu): | |
milestone: | none → ubuntu-10.04.2 |
summary: |
- sendsigs can kill upstart scripts' child processes + sendsigs can kill upstart scripts' child processes prematurely on system + shutdown |
Changed in sysvinit (Ubuntu): | |
importance: | Undecided → Medium |
status: | Confirmed → Triaged |
Changed in sysvinit (Ubuntu): | |
status: | Triaged → Won't Fix |
I might have overlooked it, but I could not find the PID of the sendsigs-revised.sh script itself as an "omit" PID inside the script. I.e. isn't there a possibility the script kills itself now? Or did I miss something?