mirror of
https://github.com/curl/curl.git
synced 2025-02-11 14:50:40 +08:00
startnew() shouldn't return a positive pid as reported in the pidfile
by the spawned server itself unless it is actually alive
This commit is contained in:
parent
9c7d4394f9
commit
69f685056d
@ -297,7 +297,7 @@ sub startnew {
|
|||||||
logmsg "startnew: $cmd\n" if ($verbose);
|
logmsg "startnew: $cmd\n" if ($verbose);
|
||||||
|
|
||||||
my $child = fork();
|
my $child = fork();
|
||||||
my $pid2;
|
my $pid2 = 0;
|
||||||
|
|
||||||
if(not defined $child) {
|
if(not defined $child) {
|
||||||
logmsg "startnew: fork() failure detected\n";
|
logmsg "startnew: fork() failure detected\n";
|
||||||
@ -336,8 +336,7 @@ sub startnew {
|
|||||||
|
|
||||||
my $count = $timeout;
|
my $count = $timeout;
|
||||||
while($count--) {
|
while($count--) {
|
||||||
if(-f $pidfile) {
|
if(-f $pidfile && -s $pidfile && open(PID, "<$pidfile")) {
|
||||||
open(PID, "<$pidfile");
|
|
||||||
$pid2 = 0 + <PID>;
|
$pid2 = 0 + <PID>;
|
||||||
close(PID);
|
close(PID);
|
||||||
if(($pid2 > 0) && kill(0, $pid2)) {
|
if(($pid2 > 0) && kill(0, $pid2)) {
|
||||||
@ -346,6 +345,8 @@ sub startnew {
|
|||||||
# similar!
|
# similar!
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
# invalidate $pid2 if not actually alive
|
||||||
|
$pid2 = 0;
|
||||||
}
|
}
|
||||||
if (checkdied($child)) {
|
if (checkdied($child)) {
|
||||||
logmsg "startnew: child process has died, server might start up\n"
|
logmsg "startnew: child process has died, server might start up\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user