Subject: | HUP crashes prefork server |
I'm using Net::Server::PreFork. I notice that when the server is sent the HUP signal, it reexecs itself, then shuts itself down. Here are the log entries when this happens:
2004/04/20-11:45:25 HUP'ing server
Pid_file created by this same process. Doing nothing.
Process Backgrounded
2004/04/20-11:45:26 Pid_file already exists for running process (309)... aborting
at line 269 in file /usr/local/share/perl/5.6.1/Net/Server.pm
2004/04/20-11:45:26 Server closing!
There appears to be a race condition on reading the process id from /proc.
Upon a HUP restart, the server backgrounds itself (it forks and the parent exits). The child then appears to read the parent's info from /proc before it is cleared out, and quits because it thinks the server is really running .
If I add a sleep for one second in the child after the fork where the server is backgrounded, the HUP restart works correctly. i.e.
### background the process
if( defined($prop->{setsid}) || defined($prop->{background}) ){
my $pid = eval{ safe_fork() };
if( not defined $pid ){ $self->fatal( $@ ); }
exit(0) if $pid;
sleep 1;
$self->log(2,"Process Backgrounded");
}