newlib: add 201-signals (broken as no default action occurs in newlib)

This commit is contained in:
Giacomo Tesio 2017-05-02 01:15:10 +02:00
parent cf974abe0e
commit 47573e2122
3 changed files with 68 additions and 2 deletions

View File

@ -30,9 +30,9 @@ main() {
signal(SIGINT,sigint);
signal(SIGQUIT, sigquit);
printf("\nChild going to loop...\n\n");
close(p[1]);
close(p[0]);
printf("\nChild going to loop...\n\n");
for(;;); /* loop for ever */
}
else /* parent */

View File

@ -0,0 +1,65 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
void sighup(); /* routines child will call upon sigtrap */
void sigint();
void sigquit();
int
main() {
int pid, p[2], w, status, sig = 0;
char dummy[1];
/* get child process */
if(pipe(p)){
perror("pipe");
exit(1);
}
if ((pid = fork()) < 0) {
perror("fork");
exit(2);
}
if (pid == 0) {
printf("\nI am the new child!\n\n");
close(p[1]);
close(p[0]);
for(;;); /* loop for ever */
}
else /* parent */
{
close(p[1]);
read(p[0], &dummy, 1);
close(p[0]);
printf("\nPARENT: sending SIGQUIT\n\n");
kill(pid,SIGQUIT);
do {
w = waitpid(pid, &status, WUNTRACED);
if (w == -1) {
perror("waitpid");
exit(EXIT_FAILURE);
}
if (WIFEXITED(status)) {
printf("exited, status=%d\n", WEXITSTATUS(status));
exit(EXIT_FAILURE);
} else if (WIFSIGNALED(status)) {
sig = WTERMSIG(status);
if(sig == SIGQUIT){
printf("killed by SIGQUIT\n");
}else{
printf("killed by signal %d\n", sig);
exit(EXIT_FAILURE);
}
} else if (WIFSTOPPED(status)) {
printf("stopped by signal %d\n", WSTOPSIG(status));
exit(EXIT_FAILURE);
}
} while (!WIFEXITED(status) && !WIFSIGNALED(status));
exit(EXIT_SUCCESS);
}
}

View File

@ -35,7 +35,8 @@
"020-waitpid.c",
"100-files.c",
"101-files.c",
"200-signals.c"
"200-signals.c",
"201-signals.c"
]
},
"NewlibTestsuite": {