mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-06 13:51:28 +00:00
This isn't technically required in those cases (we're in a definition, not in a declaration), but let's add it for consistency.
25 lines
504 B
C
25 lines
504 B
C
#define _GNU_SOURCE
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
|
|
int main(void) {
|
|
pid_t pid = vfork();
|
|
if (pid < 0) {
|
|
printf("failed on vfork (%s)\n", strerror(errno));
|
|
return -1;
|
|
}
|
|
|
|
if (pid == 0) {
|
|
printf("[pid=%d|ppid=%d] Hello, Dad!\n", getpid(), getppid());
|
|
_exit(0);
|
|
} else {
|
|
printf("[pid=%d|ppid=%d] Hello, Kid!\n", getpid(), getppid());
|
|
}
|
|
|
|
return 0;
|
|
}
|