#include #include #include #include #include int main(void) { pid_t pid = fork(); if (pid < 0){ perror("I am the parent and fork() failed"); } else if (pid != 0) { printf("I am the parent.\n"); printf("P: my pid is %d.\n", getpid()); printf("P: my child is %d.\n", pid); printf("P: my parent is %d.\n", getppid()); sleep(5); } else { printf("I am the child.\n"); printf("C: my pid is %d.\n", getpid()); printf("C: my parent is %d.\n", getppid()); sleep(5); } return 0; }