vfork() gives "Segmentation fault (core dumped)" after code is executed
Hi, I have tried to execute a simple example of vfork() to understand its working. Issue: The code completed execution as expected but terminates with a "Segmentation fault (core dumped)" error. I have read that behavior of vfork() is quite unpredictable. Can someone explain me where did I go wrong? Code: #include <sys/types.h> #include <unistd.h> #include <stdio.h> int main() { int pid = vfork(); //creating the child process if (pid == 0) //if this is a child process { printf("\nParent process is paused..."); printf("\nChild process started...\n"); } else//parent process execution { printf("\nParent process resumed...\n"); } return 0; } Output: shweta@ubuntu:~$ ./a.out Parent process is paused... Child process started... Parent process resumed... Segmentation fault (core dumped) shweta@ubuntu:~$