[zeromq-dev] czmq_new() and automatically installed signal handlers

Pieter Hintjens ph at imatix.com
Thu Jan 3 18:06:26 CET 2013


Added some comments to that commit. I think this heads in the right
direction but needs some thought to be clean and not break the API.

On Thu, Jan 3, 2013 at 5:15 PM, Felipe Cruz <felipecruz at loogica.net> wrote:
> I just made a PR to restore original sighandlers in zctx_destroy (and tests)
>
>
> 2013/1/3 Andy Ballingall TF <ballingall at thefoundry.co.uk>
>>>
>>> You're going to run into trouble if you want to exit any 0MQ loop, if
>>> your application is catching the signals, unless you emulate something
>>> like zctx_interrupted.
>>
>>
>> In this scenario, I was envisaging that the application would be obliged
>> to state whether it handled the signals in question, and if so, would
>> additionally be obliged to call a function in my library which would set
>> zctx_interrupted to 1.
>>
>>>
>>>
>>> Assuming you have an answer for that, I'd suggest a simple change; if
>>> zctx_interrupted is non-zero, don't install a signal handler.
>>>
>> Yes, that's perfect. So I'll just temporarily set zctx_interrupted to 1
>> prior to calling zctx_new() and reset it to 0 immediately afterwards so that
>> my reactor will run normally.
>>
>> Many thanks,
>> Andy
>>
>>>
>>> I've made a patch that does this:
>>>
>>> https://github.com/hintjens/czmq/commit/4491c46f2063442eafcaffcebaa31e54dc2ecdf4
>>>
>>> Waiting for someone to merge to master along with other changes at
>>> https://github.com/zeromq/czmq/pull/106.
>>>
>>> -Pieter
>>>
>>> On Mon, Dec 31, 2012 at 5:52 PM, Andy Ballingall TF
>>> <ballingall at thefoundry.co.uk> wrote:
>>> > If you call zctx_new(), then it automatically adds a signal handler
>>> > which
>>> > captures SIGINT and SIGTERM. (At least for *nix)
>>> >
>>> > I'm using czmq to add new functionality to existing applications, some
>>> > of
>>> > which already have signal handling in place, so that's going to be an
>>> > issue.
>>> >
>>> > Has anyone discussed making the signal handling addition an option when
>>> > calling zctx_new()?
>>> >
>>> > (This is the only discussion I could find and it isn't quite what I'm
>>> > after)
>>> >
>>> >
>>> > http://grokbase.com/t/zeromq/zeromq-dev/11cpsq2ccg/czmq-zctx-new-signal-handler-side-effect
>>> >
>>> > Andy
>>> >
>>> >
>>> > --
>>> > Andy Ballingall
>>> > Senior Software Engineer
>>> >
>>> > The Foundry
>>> > 6th Floor, The Communications Building,
>>> > 48, Leicester Square,
>>> > London, WC2H 7LT, UK
>>> > Tel: +44 (0)20 7968 6828 - Fax: +44 (0)20 7930 8906
>>> > Web: http://www.thefoundry.co.uk/
>>> >
>>> > The Foundry Visionmongers Ltd.
>>> > Registered in England and Wales No: 4642027
>>> >
>>> >
>>> > _______________________________________________
>>> > zeromq-dev mailing list
>>> > zeromq-dev at lists.zeromq.org
>>> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>> >
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>>
>>
>>
>> --
>> Andy Ballingall
>> Senior Software Engineer
>>
>> The Foundry
>> 6th Floor, The Communications Building,
>> 48, Leicester Square,
>> London, WC2H 7LT, UK
>> Tel: +44 (0)20 7968 6828 - Fax: +44 (0)20 7930 8906
>> Web: http://www.thefoundry.co.uk/
>>
>> The Foundry Visionmongers Ltd.
>> Registered in England and Wales No: 4642027
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list