Skip Menu |

This queue is for tickets about the Net-Server CPAN distribution.

Report information
The Basics
Id: 53001
Status: resolved
Priority: 0/
Queue: Net-Server

People
Owner: Nobody in particular
Requestors: m-uchino [...] yetipapa.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.97
Fixed in: (no value)



Subject: parent-process is exited without waiting for child process to be finished
(Sorry, my English is poor.) In any fork type servers, parent-process is exited without waiting for child process to be finished. In close_children() ----------- 1 while waitpid(-1, POSIX::WNOHANG()) > 0; ----------- This code get the signal from finished child process, but it ignores the child process which is executing. The job that wants not to be stopped before completion will catch TERM. For example, dequeue which handles the queue. Or job that wants to be over after completely saving the data of one lump. These children do not stop by TERM immediately, but parent-process think that children finished. And server closes. Or server may restart. Simplest solution. ----------- sub post_child_cleanup_hook { 1 until waitpid(-1, POSIX::WNOHANG()) == -1; } ----------- However, this does not consider HUP. Therefore, there is it as follows. ----------- sub pre_server_close_hook { 1 until waitpid(-1, POSIX::WNOHANG()) == -1; } ----------- However, we cannot know server-close-processing was started by log because it is executed before "Server closing" was written to log. I think that it may not be an important problem that HUP is not considered. Best solution. ----------- sub close_children { my $self = shift; $self->SUPER::close_children; 1 until waitpid(-1, POSIX::WNOHANG()) == -1; } ----------- This is executed only when there is child process.
Thank you. This is in the recent versions of Net::Server.