/* 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(SIGSTART, &sigAct, NULL) == -1) printSystemError("sigaction() -- ERROR"); } void blockSignal() { sigset_t blockedSet = {{0}}; sigaddset(&blockedSet, SIGSTART); sigprocmask(SIG_BLOCK, &blockedSet, NULL); } void waitForSignal() { sigset_t set; sigaddset(&set, SIGEND); 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, SIGSTART); } void sendFinishSignal(int pid) { sendSignal(pid, SIGEND); }