This program will tell about orphan process.
As of now i cannot think of any side effect of orphan process
only thing which possibly could be your ophan process eating the resources which idealy you dont want it to have
*/
#include
int main()
{
int pid;
if(0==fork())
{
printf("Child Process [%d] Parent [%d]\n",getpid(), getppid());
sleep(5);
printf("Child Process [%d] Parent [%d]\n",getpid(), getppid());
}
else
{
sleep(1);
printf("Parent Process [%d] Parent [%d]\n",getpid(), getppid());
printf("Parent Process [%d] Parent [%d]\n",getpid(), getppid());
sleep(2);
}
return 0;
}
./3_orphan
Child Process [7070] Parent [7069]
Parent Process [7069] Parent [6602]
Parent Process [7069] Parent [6602]
Child Process [7070] Parent [1]
No comments:
Post a Comment