Quote:
Originally posted by jagman
I tried to get the pid of the chil process but i get the number PID= 0 , and when i used that in the kill option the kill option interrupt all the process.
|
When you use fork() the program will be duplicated and a child process will be created that is exactly the same as the father. The only difference is the return value of fork. The pid of the child will be returned to the father and 0 will be returned to the child. SO only the child will get 0.
Use an "if" to distinguish the father from the child.
Code:
if ( PID=fork() )
{
/*I'm the father*/
.......................................
......................................
..................................
}
/*the child continues from here*/