1 |
On 6/2/2016 3:02 AM, Sam Jorna wrote: |
2 |
> On Wed, Jun 01, 2016 at 04:02:12PM -0400, Philippe Chaintreuil wrote: |
3 |
>> I'm looking at a bug [1] that is complaining that an init script |
4 |
>> doesn't wait for the child processes of the daemon to exit before it |
5 |
>> returns. |
6 |
>> |
7 |
>> I just wanted to make sure that there's not a standard/existing |
8 |
>> methodology that does this before I start adding custom code. |
9 |
>> I guess I should also make sure that this isn't something the |
10 |
>> hive-mind thinks should be punted upstream. (I've looked at the source |
11 |
>> code, and the interrupt handler just loops through the child pids and |
12 |
>> exits, it doesn't wait on the pids.) |
13 |
> |
14 |
> I haven't looked too closely at the code, but does spamd keep track |
15 |
of its own |
16 |
> children? As in, does the master process wait until the child |
17 |
processes are |
18 |
> terminated before terminating itself? If so, then perhaps you could |
19 |
force the |
20 |
> daemon into the foreground and have start-stop-daemon background it |
21 |
itself. |
22 |
|
23 |
It doesn't wait, it just sends the signal to each child & exits, no |
24 |
wait pid. Here's the interrupt handler [trimmed for relevance]: |
25 |
|
26 |
==================================================================== |
27 |
sub kill_handler { |
28 |
my ($sig) = @_; |
29 |
info("spamd: server killed by SIG$sig, shutting down"); |
30 |
|
31 |
[...] |
32 |
|
33 |
$SIG{CHLD} = 'DEFAULT'; # we're going to kill our children |
34 |
if ($scaling) { |
35 |
$scaling->set_exiting_flag(); # don't start new ones |
36 |
} |
37 |
my $killsig = am_running_on_windows() ? 'KILL' : 'INT'; |
38 |
foreach my $pid (keys %children) { |
39 |
kill($killsig, $pid) |
40 |
or info("spamd: cannot send SIG$killsig to child process [$pid]: |
41 |
$!"); |
42 |
} |
43 |
exit 0; |
44 |
} |
45 |
==================================================================== |
46 |
|
47 |
-- Philippe "Peep" Chaintreuil |