If fork() returns a negative value, the creation of a child process was unsuccessful.



fork() returns a zero to the newly created child process.



fork() returns a positive value, the process ID of the child process, to the parent. The

returned process ID is of type pid_t defined in sys/types.h. Normally, the process ID is an

integer. Moreover, a process can use function getpid() to retrieve the process ID assigned to

this process.

Hence,

If the call to fork() is executed successfully, Unix will



make two identical copies of address spaces, one for the parent and the other for the child.



Both processes will start their execution at the next statement following the fork() call.

Given an instance of parent id=2600 and child id=2603

Pid == 0 in case of child block and pid == 2603 in case of parent block which is the explanation for

A

and

C

respectively.

Getpid()

returns the process ID of the calling process.

As the statement

pid1 = getpid();

is executed , pid1 will have the process ID of the calling process. In

this case 2603 for statement

B

and 2600 for statement

D