qa: wait for child in newlib/200-signals

This commit is contained in:
Giacomo Tesio 2017-04-30 16:55:13 +02:00
parent 14934ee51f
commit bd22e5154c

View File

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <sys/wait.h>
void sighup(); /* routines child will call upon sigtrap */ void sighup(); /* routines child will call upon sigtrap */
void sigint(); void sigint();
@ -9,7 +10,7 @@ void sigquit();
int int
main() { main() {
int pid, p[2]; int pid, p[2], child, cstatus;
char dummy[1]; char dummy[1];
/* get child process */ /* get child process */
@ -47,7 +48,14 @@ main() {
sleep(3); /* pause for 3 secs */ sleep(3); /* pause for 3 secs */
printf("\nPARENT: sending SIGQUIT\n\n"); printf("\nPARENT: sending SIGQUIT\n\n");
kill(pid,SIGQUIT); kill(pid,SIGQUIT);
sleep(3); child = wait(&cstatus);
if(child == pid && cstatus == 0)
exit(0);
else
{
printf("PARENT: child exited with status %d\n", cstatus);
exit(1);
}
} }
} }