zmq4 icon indicating copy to clipboard operation
zmq4 copied to clipboard

Disable zmq's signal handling

Open clawconduce opened this issue 9 years ago • 3 comments

I'd like to be able to disable 0mq's signal handling and only use Go's signal handling. It sounds like this might be possible based on http://zguide.zeromq.org/page:all#Handling-Interrupt-Signals

This would make writing code that handles signals much easier since I wouldn't have to check if I got EINTR errors everywhere.

clawconduce avatar Jun 02 '16 21:06 clawconduce

I am not sure how to do this. Perhaps something that sends the signal back to Go. I will have to look into this.

At the moment C-code and Go-code each have there separate signal handling. See: https://github.com/pebbe/zmq4/blob/master/examples/interrupt.go

pebbe avatar Jun 03 '16 13:06 pebbe

I have done some tests, and it seems that with newer versions of Go (I am using version 1.6.2), setting a signal handler in Go also catches the signals in the C code. In example interrupts, pressing control C when the program is waiting on client.Recv doesn not interrupt the program, you get your output from ZeroMQ, and after that the signal is caught by the Go code.

pebbe avatar Jun 03 '16 13:06 pebbe

@clawconduce:

The http://zguide.zeromq.org/page:all#Handling-Interrupt-Signals link shows how you can catch a signal in your code. It does not state whether the libzmq catches signals.

You'll have to search http://api.zeromq.org/ to find a function that disables signals and request @pebbe to add a go func.

Here is how go interacts with cgo (libzmq) https://godoc.org/os/signal.

aletheia7 avatar Sep 17 '16 07:09 aletheia7