System call fork() is used to create the new process,which becomes the child process of the caller.After a new child process is created ,both the will execute the next instruction following the fork() system call.
If fork() returns negative value,creation of child process unsuccessful
fork() returns “0” to the newly created child process.
fork() returns positive value,process ID of the child process to parent.
Linux will make the exact copy of the parents address space and give it to the child process. So ,the parent and child processes have separate address spaces.
main()
{
fork();
fork();
fork();
printf("hello world");
}
— will print 8 times.
If fork() returns negative value,creation of child process unsuccessful
fork() returns “0” to the newly created child process.
fork() returns positive value,process ID of the child process to parent.
Linux will make the exact copy of the parents address space and give it to the child process. So ,the parent and child processes have separate address spaces.
{
fork();
fork();
fork();
printf("hello world");
}
— will print 8 times.
No comments:
Post a Comment