New paste Repaste Download
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
printf("hello (pid:%d)\n", (int) getpid());
int rc = fork();
if (rc < 0) {
// fork failed
exit(1);
} else if (rc == 0) {
fprintf(stderr, "fork failed\n");
// child (new process)
printf("child (pid:%d)\n", (int) getpid());
} else {
// parent goes down this path (main)
printf("parent of %d (pid:%d)\n",
rc, (int) getpid());
}
return 0;
}
Filename: None. Size: 457b. View raw, , hex, or download this file.

This paste expires on 2025-07-01 18:11:31.312456. Pasted through web.