void sig_handler(int signo)
{
fprintf(stderr, "[%s] Received %s!\n", "process1", strsignal(signo));
-
if (signo == SIGUSR1) {
fprintf(stderr, "[%s] > Notified!\n", "process1");
struct queue_message msg;
fprintf(stderr, "[%s] > Notified with value: %s!\n", "process1", strsignal(msg.signo[0]));
raise(msg.signo[0]);
}
- else if (msgrcv(qid, &msg, sizeof(int), 1, 0) > 0) {
- fprintf(stderr, "[%s] > Notified with value: %s!\n", "process1", strsignal(msg.signo[0]));
- raise(msg.signo[0]);
- }
}
else if (signo == SIGTERM) {
fprintf(stderr, "[%s] > Signalling other processes..\n", "process1");
fprintf(stderr, "[%s] > Notified with value: %s!\n", "process2", strsignal(msg.signo[0]));
raise(msg.signo[0]);
}
- else if (msgrcv(qid, &msg, sizeof(int), 2, 0) > 0) {
- fprintf(stderr, "[%s] > Notified with value: %s!\n", "process2", strsignal(msg.signo[0]));
- raise(msg.signo[0]);
- }
}
else if (signo == SIGTERM) {
fprintf(stderr, "[%s] > Signalling other processes..\n", "process2");
fprintf(stderr, "[%s] > Notified with value: %s!\n", "process3", strsignal(msg.signo[0]));
raise(msg.signo[0]);
}
- else if (msgrcv(qid, &msg, sizeof(int), 3, 0) > 0) {
- fprintf(stderr, "[%s] > Notified with value: %s!\n", "process3", strsignal(msg.signo[0]));
- raise(msg.signo[0]);
- }
}
else if (signo == SIGTERM) {
fprintf(stderr, "[%s] > Signalling other processes..\n", "process3");