#include #include #include int main() { pid_t child_pid = fork(); if (child_pid < 0) { // error code // printf("Fork Failed"); return -1; } printf("I'm process %d\n",getpid()); if (child_pid == 0) { // child code printf("I'm the child of parent process %d\n", getppid()); } else { /* child_pid > 0 */ // parent code printf("I'm the parent of child process %d\n", child_pid); } return 0; }