Available for Unix/Linux :
/* Example: create a new process using fork in C language Linux */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <stdbool.h> #include <errno.h> #include <unistd.h> int main(void) { pid_t my_pid; pid_t pid; printf("Before fork\n"); pid = fork(); if (pid == -1) { perror("Error:"); return (1); } printf("After fork\n"); my_pid = getpid(); printf("My pid is %u\n", my_pid); return (0); }