Skip to content

Commit

Permalink
Fix microsoft#1081: no need to call os.setsid() on session leader whe…
Browse files Browse the repository at this point in the history
…n attaching

If os.setsid() raises exception then the debugger client
won't be able to attach to the remote process
  • Loading branch information
fecjanky authored and int19h committed Oct 11, 2022
1 parent 646d921 commit 46efd10
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/debugpy/adapter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 46efd10

Please sign in to comment.