[zeromq-dev] zmq_term hanging
Morten Møller Riis
mortenmoellerriis at gmail.com
Mon Sep 23 07:43:57 CEST 2013
Hi guys
I'm having trouble catching SIGTERM and closing socket and context.
I have the following code (I've trimmed it down since a lot of other stuff is happening). I use the global variable term_flag to break the main loop when the program receives SIGTERM.
The problem is that when sending SIGTERM to the program it hangs at zmq_term(). Sending SIGTERM once more closes the program. Why is this happening?
int term_flag = 1;
void term(int signum)
{
fprintf(log_fp, "Received %i, closing context and socket...\n", signum);
fprintf(log_fp, "Exiting.\n");
term_flag = 0;
}
int main(int argc, char **argv) {
...
signal(SIGTERM, term);
signal(SIGINT, term);
…
while(term_flag) {
…
rc = zmq_recv(zmq_sock, &msg, 0);
if(rc!=0) break;
…
}
zmq_close(zmq_sock);
zmq_term(zmq_ctx); // hangs here
...
return 0;
}
Best regards
Morten Møller Riis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130923/fb994389/attachment.htm>
More information about the zeromq-dev
mailing list