blob: 579b24727f0e40639e126f257c7891bc902a8a6d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
int main() {
pid_t pid = getpid();
pid_t fpid = fork();
printf("own: %d\nfork: %d\n", pid, fpid);
if (fpid == 0) {
printf("parent: %d\n", getppid());
}
else if (fpid > 0) {
int childStatus;
wait(&childStatus);
printf("child exit status: %d\n", childStatus);
}
}
|