I wrote this basics forking program in C language. But the compiler issues me error. The code is
#include<stdio.h>
#include<sys/stat.h>
#include<ctype.h>
void childProcess(){
printf("From child process with process id %d\n", getpid());
}
void parentProcess(){
printf("Parent Process with id %d\n", getpid());
pid_t pid = fork();
if (pid == 0){
childProcess();
} else if (pid > 0){
printf("Parent spawned process %d\n", pid);
} else{
printf("Forking isn't supported!\n");
}
}
int main(){
parentProcess();
}
The error is
C:\Users\ADMINI~1\AppData\Local\Temp\ccORJc6N.o forking.c:(.text+0x3e): undefined reference to `fork'