mirror of
https://github.com/webmin/webmin.git
synced 2026-06-29 07:10:31 +01:00
Merge pull request #2775 from webmin/dev/fix-miniserv-restart-loop
Fix to recover from a stale PID file whose PID was reused
This commit is contained in:
10
miniserv.pl
10
miniserv.pl
@@ -139,12 +139,14 @@ if (-l $perl_path) {
|
||||
# Check vital config options
|
||||
&update_vital_config();
|
||||
|
||||
# Check if already running via the PID file
|
||||
if (open(PIDFILE, $config{'pidfile'})) {
|
||||
# Check if already running via the PID file. In foreground mode, systemd or
|
||||
# the socket bind owns duplicate-start detection.
|
||||
if (!$config{'nofork'} && !$nofork_argv && open(PIDFILE, $config{'pidfile'})) {
|
||||
my $already = <PIDFILE>;
|
||||
close(PIDFILE);
|
||||
chop($already);
|
||||
if ($already && $already != $$ && kill(0, $already)) {
|
||||
chomp($already);
|
||||
$already =~ s/^\s+|\s+$//g;
|
||||
if ($already =~ /^\d+$/ && $already != $$ && kill(0, $already)) {
|
||||
die "Webmin is already running with PID $already\n";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user