On success , the PID of the child process is returned in the parent , and 0 is returned in the child. On failure, -1 is returned in the parent, no child process is created , and errno is set appropriately.
Each process has a unique process ID(PID). The parent process ID(PPID) of the child is the PID of the parent.
In parent process fork() returns the process ID(PID) of the child process and in child process fork() returns 0 and on failure fork returns -1 in the parent process, and no child process is created.
On success, fork returns the PID of the parent process, for e.g if the parent process has a PID 3276, it will return 3276. If the newly created child does fork, it returns 0. Whereas, if fork fails, it returns -1 . In a user-created code, in such case, we make a code as follows: if (ret==-1){ perror("fork failure")}.