1 # spawn - This is ugly, OS-specific code to spawn a separate process. It
2 # also defines a function for getting the version of a path most
3 # likely to work with cranky API functions.
8 path
= os
.path
.normcase(os
.path
.abspath(path
))
11 path
= win32api
.GetShortPathName( path
)
16 if hasattr(os
, 'fork'):
18 # UNIX-ish operating system: we fork() and exec(), and we have to track
19 # the pids of our children and call waitpid() on them to avoid leaving
20 # zombies in the process table. kill_zombies() does the dirty work, and
21 # should be called periodically.
25 def spawn(bin
, *args
):
30 os
.execv( bin
, (bin
, ) + args
)
34 stat
= os
.waitpid(z
, os
.WNOHANG
)
37 elif hasattr(os
, 'spawnv'):
39 # Windows-ish OS: we use spawnv(), and stick quotes around arguments
40 # in case they contains spaces, since Windows will jam all the
41 # arguments to spawn() or exec() together into one string. The
42 # kill_zombies function is a noop.
44 def spawn(bin
, *args
):
47 nargs
.append( '"'+arg
+'"' )
48 os
.spawnv( os
.P_NOWAIT
, bin
, nargs
)
50 def kill_zombies(): pass
53 # If you get here, you may be able to write an alternative implementation
54 # of these functions for your OS.
56 def kill_zombies(): pass
58 raise OSError, 'This OS does not support fork() or spawnv().'