#include // e x i t ( . . ) , EXIT_SUCCESS #include "application-sigrt.h" #include #include #include #define __START__ 0 #define EXPECTING 1 #define OPERATING 2 #define __FINAL__ 3 sigset_t mask ; volatile sig_atomic_t state = __START__ ; void handleStart ( int signum , siginfo_t * info , void * context ) { state = OPERATING ; sigaddset (& mask , SIGRT_START ); sigprocmask ( SIG_SETMASK , & mask , NULL ); } void handleFinal ( int signum , siginfo_t * info , void * context ) { state = __FINAL__ ; sigaddset (& mask , SIGRT_FINAL ); sigprocmask ( SIG_SETMASK , & mask , NULL ); } int main ( int argc , char * argv []) { sigfillset (& mask ); sigprocmask ( SIG_SETMASK , & mask , NULL ); struct sigaction descriptor ; memset(& descriptor , 0 , sizeof ( descriptor )); descriptor.sa_flags = SA_SIGINFO ; descriptor.sa_sigaction = handleStart ; sigaction ( SIGRT_START , & descriptor , NULL ); descriptor.sa_sigaction = handleFinal ; sigaction ( SIGRT_FINAL , & descriptor , NULL ); state = EXPECTING ; sigdelset (& mask , SIGRT_START ); sigprocmask ( SIG_SETMASK , & mask , NULL ); while ( state == EXPECTING ) pause(); sigdelset (& mask , SIGRT_FINAL ); sigprocmask ( SIG_SETMASK , & mask , NULL ); while ( state == OPERATING ) { // Working on something . . . printf("f"); } exit ( EXIT_SUCCESS ); }