shiv@ubuntu:~/ds/unix$ cat orp.c
/*
* Program to create orphan process @ Linux
/*
* Program to create orphan process @ Linux
* getpid() gives process PID and
* getppid() gives process's parent ID
* here main() process ID is parent id is current shells PID
* once process becomes orphan it is adopted by init process(it's PID is 1)
*/
#include<stdio.h>
#include<unistd.h>
int main()
{
pid_t p;
/* create child process */
p=fork();
if(p==0) {
/* fork() returns Zero to child */
sleep(10);
}
printf("The child process pid is %d parent pid %d\n", getpid(), getppid());
/*parent/child waits for 20 secs and exits*/
sleep(20);
printf("\nProcess %d is done its Parent pid %d...\n", getpid(), getppid());
return 0;
}
shiv@ubuntu:~/ds/unix$ ./a.out
The child process pid is 2575 parent pid 1922
The child process pid is 2576 parent pid 2575
Process 2575 is done its Parent pid 1922...
shiv@ubuntu:~/ds/unix$
Process 2576 is done its Parent pid 1...
very useful information, the post shared was very nice
ReplyDeleteDevOps Online Training
this one is the important topic.its very useful for everyone.thanks for shared this blog.
ReplyDeleteFull Stack Training in Chennai | Certification | Online Training Course | Full Stack Training in Bangalore | Certification | Online Training Course | Full Stack Training in Hyderabad | Certification | Online Training Course | Full Stack Training in Pune | Certification | Online Training Course | Full Stack Training | Certification | Full Stack Online Training Course
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteDevOps Training in Bangalore | Certification | Online Training Course institute | DevOps Training in Hyderabad | Certification | Online Training Course institute | DevOps Training in Coimbatore | Certification | Online Training Course institute | DevOps Online Training | Certification | Devops Training Online