[pve-devel] [PATCH common 1/2] tools: add pipe_socket_to_command

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Aug 3 17:27:46 CEST 2017


Forgot to mention that this is only almost a copy/paste:

On 08/03/2017 05:11 PM, Thomas Lamprecht wrote:
> +    if (waitpid($pid, 0) != $pid) {
> +	kill(15 => $pid); # if we got interrupted terminate the child
> +	my $count = 0;
> +	while (waitpid($pid, POSIX::WNOHANG) != $pid) {
> +	    usleep(100000);
> +	    $count++;
> +	    kill(9 => $pid) if $count > 300; # 30 second timeout
> +	}
> +    }

I mainly changed the waitpid part a bit from Wolfgang's version to make
it more graceful. I.e. do not send straight away a SIGKILL, but SIGTERM.
Then after 30 seconds a SIGKILL, if still needed.
I am not sure if its then wise to still endlessly wait thereafter. If
the child process hangs in an uninterruptible sleep state we would hang
too, forever? We could return then after one last try to collect the 
state, the child will never do anything anyways, if it gets release from
the uninterruptible sleep the SIGKILL will get immediately delivered and
kill it.




More information about the pve-devel mailing list