old file
This commit is contained in:
parent
e1236f857a
commit
6db7f23e35
16
a.py
16
a.py
|
@ -1,16 +0,0 @@
|
||||||
import os, socket
|
|
||||||
|
|
||||||
def CreateChild(*args):
|
|
||||||
'''
|
|
||||||
Create a child process whos stdin/stdout is connected to a socketpair.
|
|
||||||
Returns:
|
|
||||||
fd
|
|
||||||
'''
|
|
||||||
sock1, sock2 = socket.socketpair()
|
|
||||||
if os.fork():
|
|
||||||
for pair in ((0, sock1), (1, sock2)):
|
|
||||||
os.dup2(sock2.fileno(), pair[0])
|
|
||||||
os.close(pair[1].fileno())
|
|
||||||
os.execvp(args[0], args)
|
|
||||||
raise SystemExit
|
|
||||||
return sock1
|
|
Loading…
Reference in New Issue