You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According the description in section Handling Interrupt Signals the signal handler sets the global variable s_interrupted.
The program provides s_catch_signals(), which traps Ctrl-C (SIGINT) and SIGTERM. When either
of these signals arrive, the s_catch_signals() handler sets the global variable s_interrupted.
Thanks to your signal handler, your application will not die automatically. Instead, you have a
chance to clean up and exit gracefully.
However, the C example implements a different approach. It uses a pipe instead of the global variable.
From interrupt.c:
// Shows how to handle Ctrl-C
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <zmq.h>
// Signal handling
//
// Create a self-pipe and call s_catch_signals(pipe's writefd) in your application
// at startup, and then exit your main loop if your pipe contains any data.
// Works especially well with zmq_poll.
#define S_NOTIFY_MSG " "
#define S_ERROR_MSG "Error while writing to self-pipe.\n"
static int s_fd;
static void s_signal_handler (int signal_value)
{
int rc = write (s_fd, S_NOTIFY_MSG, sizeof(S_NOTIFY_MSG));
if (rc != sizeof(S_NOTIFY_MSG)) {
write (STDOUT_FILENO, S_ERROR_MSG, sizeof(S_ERROR_MSG)-1);
exit(1);
}
}
...
The text was updated successfully, but these errors were encountered:
According the description in section Handling Interrupt Signals the signal handler sets the global variable s_interrupted.
However, the C example implements a different approach. It uses a pipe instead of the global variable.
From interrupt.c:
The text was updated successfully, but these errors were encountered: