fork () Function Explained With Simple Example

Fork () is a system call in unix which can be used by a process to create a new process. This is a special function which is called once but it returns twice, one for parent process who called the fork () and second for the child process which is created by fork (). Fork () returns process id of the new process in parent process whereas it returns 0 for child process.

Syntax of fork () function call is as follows:

#include <unistd.h>
pid_t fork(void);   /* Returns: 0 in child, process ID of child in parent, −1 on error */
(more…)
fork () Function Explained With Simple Example Read More