]> granicus.if.org Git - python/commitdiff
The webbrowser module now uses subprocess's start_new_session=True rather
authorGregory P. Smith <greg@krypto.org>
Wed, 27 Aug 2014 16:34:38 +0000 (09:34 -0700)
committerGregory P. Smith <greg@krypto.org>
Wed, 27 Aug 2014 16:34:38 +0000 (09:34 -0700)
than a potentially risky preexec_fn=os.setsid call.

Lib/webbrowser.py
Misc/NEWS

index 9e47084a91b587be0162b54aaeafbd85b1ffd6f0..845f1d004c0b48d4b86d9fec57becc6cf18d3497 100755 (executable)
@@ -159,10 +159,8 @@ class BackgroundBrowser(GenericBrowser):
             if sys.platform[:3] == 'win':
                 p = subprocess.Popen(cmdline)
             else:
-                setsid = getattr(os, 'setsid', None)
-                if not setsid:
-                    setsid = getattr(os, 'setpgrp', None)
-                p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid)
+                p = subprocess.Popen(cmdline, close_fds=True,
+                                     start_new_session=True)
             return (p.poll() is None)
         except OSError:
             return False
@@ -321,11 +319,6 @@ class Konqueror(BaseBrowser):
             action = "openURL"
 
         devnull = subprocess.DEVNULL
-        # if possible, put browser in separate process group, so
-        # keyboard interrupts don't affect browser as well as Python
-        setsid = getattr(os, 'setsid', None)
-        if not setsid:
-            setsid = getattr(os, 'setpgrp', None)
 
         try:
             p = subprocess.Popen(["kfmclient", action, url],
@@ -343,7 +336,7 @@ class Konqueror(BaseBrowser):
             p = subprocess.Popen(["konqueror", "--silent", url],
                                  close_fds=True, stdin=devnull,
                                  stdout=devnull, stderr=devnull,
-                                 preexec_fn=setsid)
+                                 start_new_session=True)
         except OSError:
             # fall through to next variant
             pass
@@ -356,7 +349,7 @@ class Konqueror(BaseBrowser):
             p = subprocess.Popen(["kfm", "-d", url],
                                  close_fds=True, stdin=devnull,
                                  stdout=devnull, stderr=devnull,
-                                 preexec_fn=setsid)
+                                 start_new_session=True)
         except OSError:
             return False
         else:
index 7028cf161de85e69666712bce9fef808c2016dae..bc9086123fdd6226752b93085bcbf25be743ad94 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,9 @@ Core and Builtins
 Library
 -------
 
+- The webbrowser module now uses subprocess's start_new_session=True rather
+  than a potentially risky preexec_fn=os.setsid call.
+
 - Issue #22236: Fixed Tkinter images copying operations in NoDefaultRoot mode.
 
 - Issue #22191: Fix warnings.__all__.