Method fork
fork()
Creates a new process by duplicating the calling process.
public static extern int fork()
Returns
- int
The process ID of the child process in the parent,
0in the child process, or-1if an error occurs.
Remarks
This method is a direct wrapper for the POSIX fork system call.
It creates a child process that is a copy of the calling process,
except for certain differences such as
process ID and resource allocations.
The return value distinguishes the parent process from the child process:
- In the parent process, the return value is the process ID of the child.
- In the child process, the return value
is
0. - If an error occurs, the return value is
-1, anderrnois set to indicate the error.