[pygtk] how to close the X connection file descriptor?
George Young
gry@ll.mit.edu
Tue, 14 Nov 2000 16:21:40 -0500
my pygtk app forks and execs another process which it
wants to completly disassociate from the parent.
It seems that one of the techniques necessary is for the child to
dup2 and then close all it's files, e.g.:
fdnull = open('/dev/null')
stderr_d = os.dup2(fdnull.fileno(), sys.stderr.fileno())
stdin_d = os.dup2(fdnull.fileno(), sys.stdin.fileno())
stdout_d = os.dup2(fdnull.fileno(), sys.stdout.fileno())
fdnull.close()
This works fine except for the connection to the X server.
Guessing and handcoding the number, e.g.:
foo = os.dup2(fdnull.fileno(), 5)
works, but it's not very robust. Is there any way to
get a handle on the file descriptor from the top-level
window object?