bpo-38435: Detect preexec_fn=os.setsid as start_new_session=True

This is a somewhat common use case, this makes it more reliable.
This commit is contained in:
Gregory P. Smith 2020-12-24 22:26:17 -08:00
parent c6c43b2874
commit 9d365ba4b3
1 changed files with 4 additions and 0 deletions

View File

@ -937,6 +937,10 @@ class Popen(object):
if uid < 0:
raise ValueError(f"User ID cannot be negative, got {uid}")
if preexec_fn == os.setsid: # A common unnecessary legacy use.
start_new_session = True
preexec_fn = None
try:
if p2cwrite != -1:
self.stdin = io.open(p2cwrite, 'wb', bufsize)