I have a child process which has received a SIGTSTP signal. When I call
waitpid(-1,NULL,0);
the parent blocks, but in documentation, its written that waitpid returns with pid for stopped jobs.
#include<unistd.h>
#include<stdio.h>
#include<signal.h>
#include<sys/wait.h>
main() {
int pid;
if( (pid=fork()) > 0) {
sleep(5);
if(kill(pid,SIGTSTP) < 0)
printf("kill error\n");
int status;
waitpid(-1,&status,0);
printf("Returned %d\n",WIFSTOPPED(status));
}
else if(pid==0) {
while(1);
}
}