Fix #1081: no need to call os.setsid() on session leader when attaching

If os.setsid() raises exception then the debugger client
won't be able to attach to the remote process
This commit is contained in:
Janky Ferenc Nandor 2022-10-10 19:14:05 +02:00 committed by Pavel Minaev
parent 646d921dc1
commit 46efd10d4a

View file

@ -30,7 +30,10 @@ def main(args):
# On POSIX, we need to leave the process group and its session, and then
# daemonize properly by double-forking (first fork already happened when
# this process was spawned).
os.setsid()
# NOTE: if process is already the session leader, then
# setsid would fail with `operation not permitted`
if os.getsid(os.getpid()) != os.getpid():
os.setsid()
if os.fork() != 0:
sys.exit(0)