[zeromq-dev] CZMQ zctx_new signal handler side effect

Pieter Hintjens ph at imatix.com
Thu Dec 22 07:45:43 CET 2011


On Wed, Dec 21, 2011 at 10:59 PM, Philip Kovacs <kovacsp3 at comcast.net> wrote:

> If you run a reactor (zloop) in the main thread, I can see where the signal
> handling is helpful, but consider the case where you run zloops in attached
> threads.  If the process gets a SIGTERM or SIGINT, the attached threads
> shutdown cleanly, but the main thread ends up in an unexpected state.
> You can have the main thread regain control of signal handling, of course,
> by using sigaction after each zctx_new, but in that case, you are fighting
> the czmq library.

Hmm, it is true that shutting down a multithreaded app is delicate.
You need to inform the parent thread via its pipe, and the parent
needs to then exit explicitly. I don't think it would help to have
signals caught by the parent; you would then get child threads not
exiting properly.

-Pieter



More information about the zeromq-dev mailing list