Global variables are not updated in signal handlers unless of atomic types like sig_atomic_t
. Given the following 2 conditions, can I safely edit global variables in signal handler?
- If I define only one signal handler
- If I use a
sa_mask
ofstruct sigaction
to block all signals for the handler - Application is single threaded
Adding more details: I got a small global linked list keeping some info of its child process in it. Once I catch SIGCHLD (in parent process), in my signal handler I want to delete that node from the linked list. Can I perform this action in signal handler with above conditions and using some sort of pthread_mutex_trylock()?