mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-20104: Expose posix_spawn
in the os module (GH-5109)
Add os.posix_spawn to wrap the low level POSIX API of the same name. Contributed by Pablo Galindo.
This commit is contained in:
parent
f5b04a360e
commit
6c6ddf97c4
7 changed files with 277 additions and 4 deletions
|
@ -176,6 +176,23 @@ class PosixTester(unittest.TestCase):
|
|||
finally:
|
||||
os.close(fp)
|
||||
|
||||
|
||||
@unittest.skipUnless(hasattr(os, 'posix_spawn'), "test needs os.posix_spawn")
|
||||
def test_posix_spawn(self):
|
||||
pid = posix.posix_spawn(sys.executable, [sys.executable, "-c", "pass"], os.environ,[])
|
||||
self.assertEqual(os.waitpid(pid,0),(pid,0))
|
||||
|
||||
|
||||
@unittest.skipUnless(hasattr(os, 'posix_spawn'), "test needs os.posix_spawn")
|
||||
def test_posix_spawn_file_actions(self):
|
||||
file_actions = []
|
||||
file_actions.append((0,3,os.path.realpath(__file__),0,0))
|
||||
file_actions.append((os.POSIX_SPAWN_CLOSE,2))
|
||||
file_actions.append((os.POSIX_SPAWN_DUP2,1,4))
|
||||
pid = posix.posix_spawn(sys.executable, [sys.executable, "-c", "pass"], os.environ, file_actions)
|
||||
self.assertEqual(os.waitpid(pid,0),(pid,0))
|
||||
|
||||
|
||||
@unittest.skipUnless(hasattr(posix, 'waitid'), "test needs posix.waitid()")
|
||||
@unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
|
||||
def test_waitid(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue