Networking Reference
In-Depth Information
SIGINT : This signal can be caught by the application just like SIGTERM as well.
The user usually calls it with Ctrl + C .
SIGKILL : This is the signal that is called with a kill -9 command. However,
this signal cannot be caught by an application, so there is nothing much we
could do about it.
SIGINT could be caught in languages that support exception handling by throwing
the proper exception such as KeyboardInterrupt in Python. However, things are a
little bit different in C.
Let's recall our "hello world" request-reply program to demonstrate the handling of
the SIGTERM ( Ctrl + C ) interrupt.
Request - Reply
Handling interrupts.
#include <string.h>
#include <stdio.h>
#include "czmq.h"
int main (int argc, char const *argv[]) {
zctx_t* context = zctx_new();
void* socket = zsocket_new(context, ZMQ_REP);
zsocket_bind(socket, "tcp://*:5050");
printf("Starting server...\n");
for(;;) {
char* msg = zstr_recv(socket);
if(!msg) {
Search MirCeyron ::

Custom Search