I need to resume after calling pause()
, from what I read of the manual, it should resume after it receives a signal, but apparently is not working for me, also I'm using a semaphore to make sure that the program register the signal handler before I send the signal to resume it
void child(){
fprintf(stdout,"Hello!\n");
exit(0);
}
int main(int argc, char **argv){
sem_t sem;
sem_init(&sem,0,0);
int pid = fork();
if(pid == 0){
signal(SIGCONT, child);
sem_post(&sem);
pause();
} else {
sem_wait(&sem);
kill(pid, SIGCONT);
int status;
waitpid(pid,&status, 0);
}
return EXIT_SUCCESS;
}
This is not the actual program that I'm working on, but it has the structure of it.
What is happening is that the parent hangs at waitpid()
and the child never leaves the pause()
call, I know this because it never prints the message "Hello!"