[zeromq-dev] (py)zmq, fork and cloexec

Ivan Pechorin ivan.pechorin at gmail.com
Wed Jun 20 17:04:11 CEST 2012

2012/6/20 Christian Heimes <lists at cheimes.de>

> You'd have to register all file descriptors in a
> central registry, remove the FDs on close and close() the FDs after
> fork(). That's lots of work but C++ should make it easie
Sounds too complex: why not just close() all the FDs >= 3 after fork(),
before exec*() ?

Linux and all major types of UNIXes have efficient way to do so (without
iterating up to resource limit).

Like these:
 - Solaris: closefrom(3);
 - AIX: fcntl(3, F_CLOSEM, 0);
 - HP-UX:
            struct pst_status ps;
            pstat_getproc(&ps, sizeof(struct pst_status), (size_t)0,
            for (int fd = 3; fd < ps.pst_highestfd; fd++)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120620/ebd9ebd2/attachment.htm>

More information about the zeromq-dev mailing list