/* This is a personal academic project. Dear PVS-Studio, please check it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com */ #define _POSIX_C_SOURCE 200112L #include "siglib.h" #include #include "error.h" #include void addSignalHandler(void (*changeViewFlag)()) { struct sigaction sigAct = {{0}}; sigAct.sa_handler = changeViewFlag; sigAct.sa_flags = 0; if (sigaction(SIGUSR1, &sigAct, NULL) == -1) printSystemError("sigaction() -- ERROR"); } // PodrĂ­amos de Ășltima hacer que devuelvan el sigset para no tener dos distintos... void blockSignal() { sigset_t blockedSet = {{0}}; sigaddset(&blockedSet, SIGUSR1); sigprocmask(SIG_BLOCK, &blockedSet, NULL); } void waitForSignal() { sigset_t set; sigaddset(&set, SIGUSR2); int temp; sigwait(&set, &temp); } void sendSignal(int pid, int sig) { union sigval value = {0}; sigqueue(pid, sig, value); } void sendStartSignal(int pid) { sendSignal(pid, SIGUSR1); } void sendFinishSignal(int pid) { sendSignal(pid, SIGUSR2); }