wip post
This commit is contained in:
parent
c8a2913172
commit
5a1c98d8a4
8 changed files with 170 additions and 0 deletions
21
content/posts/debugging-rr-children/caller.c
Normal file
21
content/posts/debugging-rr-children/caller.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue