mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2024-11-24 00:53:39 +01:00
vncserver: replace -kill sleep with a faster busyloop
This commit is contained in:
parent
8ca36e349e
commit
0ca46888a0
@ -375,7 +375,9 @@ sub Kill
|
||||
|
||||
if (kill 0, $pid) {
|
||||
system("kill $pid");
|
||||
sleep(1);
|
||||
&WaitForTimeLimitOrSubReturningTrue(1, sub {
|
||||
!IsProcessRunning($pid)
|
||||
});
|
||||
if (kill 0, $pid) {
|
||||
print "Xvnc seems to be deadlocked. Kill the process manually and then re-run\n";
|
||||
print " ".$0." -kill ".$opt{'-kill'}."\n";
|
||||
@ -1069,3 +1071,20 @@ sub StartXvncOrExit {
|
||||
&WarnUserXvncNotStartedAndExit();
|
||||
}
|
||||
}
|
||||
|
||||
sub WaitForTimeLimitOrSubReturningTrue {
|
||||
my ($timeLimit, $sub) = @_;
|
||||
my $sleepSlice = 0.05;
|
||||
my $sleptFor = 0;
|
||||
|
||||
until (&$sub() || $sleptFor >= $timeLimit) {
|
||||
sleep($sleepSlice);
|
||||
$sleptFor += $sleepSlice;
|
||||
}
|
||||
}
|
||||
|
||||
sub IsProcessRunning {
|
||||
my $pid = shift;
|
||||
|
||||
kill 0, $pid;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user