From: Michal Srb Date: Thu, 1 Oct 2015 23:28:26 +0000 (+0300) Subject: vncserver: Clean pid files of dead processes. X-Git-Tag: v1.5.90~13^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e6e11f9a3ae7233a32034d4e72674561859ad663;p=tigervnc.git vncserver: Clean pid files of dead processes. When Xvnc fails to start, delete the pid file. Clean pid files of dead processes when listing them as well. --- diff --git a/unix/vncserver b/unix/vncserver index 9ff24411..64d10c5b 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -302,6 +302,7 @@ if ($fontPath ne $defFontPath) { } unless (kill 0, `cat $pidFile`) { warn "Could not start Xvnc.\n\n"; + unlink $pidFile; open(LOG, "<$desktopLog"); while () { print; } close(LOG); @@ -587,7 +588,12 @@ sub List print "X DISPLAY #\tPROCESS ID\n"; foreach my $file (@filelist) { if ($file =~ /$host:(\d+)$\.pid/) { - print ":".$1."\t\t".`cat $vncUserDir/$file`; + chop($tmp_pid = `cat $vncUserDir/$file`); + if (kill 0, $tmp_pid) { + print ":".$1."\t\t".`cat $vncUserDir/$file`; + } else { + unlink ($vncUserDir . "/" . $file); + } } } exit 1;