From 21afd01ce22f898dc19e88d31c76da1ea2596b96 Mon Sep 17 00:00:00 2001 From: Nicholas Riley Date: Sun, 24 Sep 2000 06:28:47 +0000 Subject: Change for Python 1.6 compatibility - UNIX's 'os' module defines 'spawnv' now, so we check for 'fork' first. --- Lib/idlelib/spawn.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Lib/idlelib/spawn.py b/Lib/idlelib/spawn.py index ce6b41c..22617ed 100644 --- a/Lib/idlelib/spawn.py +++ b/Lib/idlelib/spawn.py @@ -13,22 +13,7 @@ def hardpath(path): pass return path -if hasattr(os, 'spawnv'): - - # Windows-ish OS: we use spawnv(), and stick quotes around arguments - # in case they contains spaces, since Windows will jam all the - # arguments to spawn() or exec() together into one string. The - # kill_zombies function is a noop. - - def spawn(bin, *args): - nargs = [bin] - for arg in args: - nargs.append( '"'+arg+'"' ) - os.spawnv( os.P_NOWAIT, bin, nargs ) - - def kill_zombies(): pass - -elif hasattr(os, 'fork'): +if hasattr(os, 'fork'): # UNIX-ish operating system: we fork() and exec(), and we have to track # the pids of our children and call waitpid() on them to avoid leaving @@ -49,6 +34,20 @@ elif hasattr(os, 'fork'): stat = os.waitpid(z, os.WNOHANG) if stat[0]==z: zombies.remove(z) +elif hasattr(os, 'spawnv'): + + # Windows-ish OS: we use spawnv(), and stick quotes around arguments + # in case they contains spaces, since Windows will jam all the + # arguments to spawn() or exec() together into one string. The + # kill_zombies function is a noop. + + def spawn(bin, *args): + nargs = [bin] + for arg in args: + nargs.append( '"'+arg+'"' ) + os.spawnv( os.P_NOWAIT, bin, nargs ) + + def kill_zombies(): pass else: # If you get here, you may be able to write an alternative implementation -- cgit v0.12