X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2FPVE%2FRESTEnvironment.pm;h=338a534d4abcec6d4eb1292b04f4d3720dc41636;hb=4cbcd1386f225f42896fe790337d152718498693;hp=32ffdd157f48a898697f77f7b582df471c5f6f64;hpb=8733bb8078f7c5d79582dfdd177db306cbc3c9e9;p=pve-common.git diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm index 32ffdd1..338a534 100644 --- a/src/PVE/RESTEnvironment.pm +++ b/src/PVE/RESTEnvironment.pm @@ -494,10 +494,17 @@ sub fork_worker { $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { die "received interrupt\n"; }; $SIG{CHLD} = $SIG{PIPE} = 'DEFAULT'; - - # set sess/process group - we want to be able to kill the - # whole process group - POSIX::setsid(); + $SIG{TTOU} = 'IGNORE'; + + # set session/process group allows to kill the process group + if ($sync && -t STDIN) { + # some sync'ed workers operate on the tty but setsid sessions lose + # the tty, so just create a new pgroup and give it the tty + POSIX::setpgid(0, 0) or die "failed to setpgid: $!\n"; + POSIX::tcsetpgrp(fileno(STDIN), $$) or die "failed to tcsetpgrp: $!\n"; + } else { + POSIX::setsid(); + } POSIX::close ($psync[0]); POSIX::close ($ctrlfd[0]) if $sync;