[Xcb] closing xcb connection after fork() call

Rémi Denis-Courmont remi at remlab.net
Mon Mar 4 23:37:10 PST 2013


On Mon, 4 Mar 2013 20:22:19 -0500, Micah Nordland <mpnordland at gmail.com>
wrote:
> Should I call xcb_disconnect on the xcb_connection_t after I've forked,
or
> should I get at the file descriptor using xcb_get_file_descriptor() and
> just close() it? What I'm trying to do is have my application launch
> another app using the double fork() trick.

In my understanding, as XCB uses POSIX threads internally, XCB functions
cannot be used safely after fork() returns zero.

The XCB sockets are created with close-on-exec, so you do not need to
care. The XCB socket will be automatically closed and the XCB memory will
be freed through process overlay once you call exec().

-- 
Rémi Denis-Courmont
Sent from my collocated server


More information about the Xcb mailing list