Code:
/*name of the built program is dmns*/
int main()
{
int i, j;
i=fork();
if(i<0)
return 1;
printf("created pid=%d",i);
while(1) {i=i;} //unlimited loop
}
after running the program on another console I check the process running.
Code:
#ps -ef|grep dmns root 20117 20065 44 23:44 pts/1 00:00:03 ./dmns root 20118 20117 44 23:44 pts/1 00:00:03 ./dmns
If I kill the process 20118 then the ps -ef result is
Code:
#ps -ef|grep dmns root 20117 20065 44 23:44 pts/1 00:00:03 ./dmns root 20118 20117 44 23:44 pts/1 00:00:03 [dmns] <defunct>
Code:
#ps -ef|grep dmns root 20118 20117 44 23:44 pts/1 00:00:03 ./dmns
Code:
/*name of the built program is dmns*/
int main()
{
int i, j;
i=fork();
if(i<0)
exit(1);
if(i>0)
exit(0);
...
}
Comment