0
1
mirror of https://github.com/termux/proot.git synced 2024-11-27 04:19:04 +00:00
proot/tests/test-77777777.c.unreliable
2016-08-21 07:42:00 -04:00

52 lines
1018 B
Plaintext

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
int child_status;
int status;
pid_t pid;
pid = fork();
switch (pid) {
case -1:
perror("fork()");
exit(EXIT_FAILURE);
case 0: /* child */
status = raise(SIGSTOP);
if (status != 0) {
perror("raise(SIGSTOP)");
exit(EXIT_FAILURE);
}
sleep(1);
exit(EXIT_FAILURE);
default: /* parent */
status = waitpid(pid, &child_status, WUNTRACED);
if (status < 0) {
perror("waitpid()");
exit(EXIT_FAILURE);
}
if (WIFEXITED(child_status))
printf("exited, status=%d\n", WEXITSTATUS(child_status));
else if (WIFSIGNALED(child_status))
printf("killed by signal %d\n", WTERMSIG(child_status));
else if (WIFSTOPPED(child_status))
printf("stopped by signal %d\n", WSTOPSIG(child_status));
else if (WIFCONTINUED(child_status))
printf("continued\n");
if (WIFSTOPPED(child_status))
exit(EXIT_SUCCESS);
else
exit(EXIT_FAILURE);
}
}