I want to know what happens to a process when it is sleeping a receive a signal, and how to force it to complete the inicial wait in spite of the signal.
I think that when a process is sleeping (with sleep() for example), when it receives a signal it is automatically awaken from the sleep. And in order to force it to complete the wait I'm not sure, I don't know if something like this could work:
if ((pid = waitpid(-1, &status, 0)) > 0)
{
if (WIFSIGNALED(status))
printf("PID %d exited due to signal %d\n.",
childpid,
WTERMSIG(status));
}
Correct me if I'm wrong please and I would appreciate if someone could enlighen me with that, I don't necesarilly need much code, I want to know it mostly theoretically. Thank you in advance.