#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main() {
pid_t pid;
pid = fork(); // Create a child process
if (pid < 0) { // Error handling
fprintf(stderr, "Fork failed\n");
return 1;
} else if (pid == 0) { // Child process
printf("This is the child process, with PID: %d\n", getpid());
} else { // Parent process
printf("This is the parent process, with PID: %d\n", getpid());
printf("Child process created with PID: %d\n", pid);
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: