Very Basic Stuff
1) To check process Id getpid()
2) To check process Id of parent process getppid()
3) To check process table “ps -el”
4) They say swapper process or scheduler process is the first process created with process Id 0. This process is responsible for allocating memory and scheduling process.
5) In program below
int main()
{
int pid;
pid = fork ();
if(pid ==0)
{
// this will be child process
}
else
{
//this will be the parent process
}
}
All I wanted to communicate is that for return 0 to the child process and newly created Process Id to the parent process. As it happens every where if system call fails it will return -1.
You could remember this 0 return value from the fact that. Every thing present after the fork() is executed for the child process. So effectively the statement “pid = fork()” will never get executed for the child hence the value will be 0.
No comments:
Post a Comment