blog/content/posts/debugging-rr-children/caller.c
Jade Lovelace 5a1c98d8a4 wip post
2022-03-14 15:14:47 -07:00

21 lines
599 B
C

#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
int main(void) {
int pid = fork();
if (pid == -1) {
perror("fork");
return 1;
} else if (pid == 0) {
execl("./crasher", "./crasher", NULL);
return 1;
} else {
// parent
int status;
printf("[caller] spawned pid %d\n", pid);
int ret = waitpid(pid, &status, 0);
printf("[caller] waitpid: %d, exited? %d status %d, signaled? %d signal %d\n", ret, WIFEXITED(status), WEXITSTATUS(status), WIFSIGNALED(status), WTERMSIG(status));
return 0;
}
}