https://www.virtualmin.com/node/19209
authorJamie Cameron <jcameron@webmin.com>
Tue, 16 Aug 2011 21:11:52 +0000 (14:11 -0700)
committerJamie Cameron <jcameron@webmin.com>
Tue, 16 Aug 2011 21:11:52 +0000 (14:11 -0700)
Handle case where miniserv was restarted twice in the same process

web-lib-funcs.pl

index 33dfbf0..d0042bd 100755 (executable)
@@ -1882,7 +1882,7 @@ if ($gconfig{'os_type'} ne 'windows') {
        $miniserv{'inetd'} && return;
        my @oldst = stat($miniserv{'pidfile'});
        $pid = $ENV{'MINISERV_PID'};
-       if (!$pid) {
+       if (!$pid || !kill(0, $pid)) {
                if (!open(PID, $miniserv{'pidfile'})) {
                        print STDERR "PID file $miniserv{'pidfile'} does ",
                                     "not exist\n";
@@ -1961,7 +1961,7 @@ if ($gconfig{'os_type'} ne 'windows') {
        my ($pid, $addr, $i);
        $miniserv{'inetd'} && return;
        $pid = $ENV{'MINISERV_PID'};
-       if (!$pid) {
+       if (!$pid || !kill(0, $pid)) {
                if (!open(PID, $miniserv{'pidfile'})) {
                        print STDERR "PID file $miniserv{'pidfile'} does ",
                                     "not exist\n";