Better child kill.

This commit is contained in:
sergiotarxz 2021-11-14 01:18:27 +01:00
parent dd1d7c783f
commit 590b56e610

View File

@ -16,6 +16,7 @@ use Cualsea::Server::MonitorController;
my $pid = fork; my $pid = fork;
if ($pid) {{ if ($pid) {{
local $SIG{INT} = \&finish_parent; local $SIG{INT} = \&finish_parent;
local $SIG{TERM} = \&finish_parent;
while (1) { while (1) {
my $loop = Cualsea::Server::Loop->new; my $loop = Cualsea::Server::Loop->new;
try { try {
@ -33,7 +34,7 @@ while (1) {
} }
sub finish_parent { sub finish_parent {
kill 'INT', $pid; kill 'KILL', $pid;
1 while waitpid $pid, WNOHANG; 1 while waitpid $pid, WNOHANG;
exit; exit;
} }