[zeromq-dev] forking processes and closing file descriptors and io threads.
Matt Connolly
matt.connolly at me.com
Sun Aug 11 01:45:27 CEST 2013
Hi all,
Following my recent problem with the rbczmq bindings gem, I’ve done a bit more reading about the use of fork with ZeroMQ and it seems to me that it isn’t well supported due to shared resources and threads cloned from the parent process to the child process.
I’ve updated the rbczmq gem to not destroy the context inherited from the parent, which resolves the previous assert I experienced. However, I’m expecting some other problems based on discussion in these threads:
http://lists.zeromq.org/pipermail/zeromq-dev/2012-October/018911.html
http://lists.zeromq.org/pipermail/zeromq-dev/2012-June/017571.html
http://lists.zeromq.org/pipermail/zeromq-dev/2012-April/016840.html
Simply not closing the context, however, leaves the file descriptors open and inherited io threads running, which I expect will cause problems.
Is there a way to safely close these file descriptors and terminate the inherited io threads?
If not, I could guess two solutions:
1. Add a new API call to do this that child processes could call after fork, or
2. Alter the zmq_ctx_destroy() to realise that it is being called from a different process and perform a simplified shutdown.
I haven’t delved too much into the internals of zeromq, so advice is appreciated.
Thanks,
Matt.
More information about the zeromq-dev
mailing list