fork() is
used create a new child process.
Ø No arguments
Ø Process ID of the child process
Ø After the execution of fork() command both parent & child processes are starting their execution from the next line.
Ø No arguments
Ø Process ID of the child process
Ø After the execution of fork() command both parent & child processes are starting their execution from the next line.
Conditions of fork()
Ø fork() > 0 -: not only a child process but also a parent process (Successfully child process created.)
Ø fork() == 0 -: a child process (Successfully child process created.)
Ø fork() < 0 -: error in memory allocation (Unsuccessful child process)
Ø fork() > 0 -: not only a child process but also a parent process (Successfully child process created.)
Ø fork() == 0 -: a child process (Successfully child process created.)
Ø fork() < 0 -: error in memory allocation (Unsuccessful child process)
Example: