Professional Documents
Culture Documents
Time to unleash full potential! Experience unlimited, unhindered learning with GeeksforGeeks
Premium! Only 1000 seats available, Grab Yours Now!
Both getppid() and getpid() are inbuilt functions de ned in unistd.h library.
1. getppid() : returns the process ID of the parent of the calling process. If the calling
process was created by the fork() function and the parent process still exists at the
time of the getppid function call, this function returns the process ID of the parent
process. Otherwise, this function returns a value of 1 which is the process id for init
process.
Syntax:
pid_t getppid(void);
Return type: getppid() returns the process ID of the parent of the current process. It
never throws any error therefore is always successful.
https://www.geeksforgeeks.org/getppid-getpid-linux/ 1/4
10/10/2020 getppid() and getpid() in Linux - GeeksforGeeks
NOTE: At some instance of time, it is not necessary that child process will execute rst
or parent process will be rst allotted CPU, any process may get CPU assigned, at
some quantum time. Moreover process id may differ during different executions.
2. getpid() : returns the process ID of the calling process. This is often used by routines
that generate unique temporary lenames.
Syntax:
pid_t getpid(void);
Return type: getpid() returns the process ID of the current process. It never throws any
error therefore is always successful.
We use cookies to ensure you have the best browsing experience on our website. By using our
Got It !
site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
https://www.geeksforgeeks.org/getppid-getpid-linux/ 2/4
10/10/2020 getppid() and getpid() in Linux - GeeksforGeeks
This article is contributed by Pushpanjali Chauhan. If you like GeeksforGeeks and would like
to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your
article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks
main page and help other Geeks.
Please write comments if you nd anything incorrect, or you want to share more information
about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with
the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
Practice Tags : C
Be the First to upvote.
1.5
To-do Done Based on 2 vote(s)
Improve Article
We use cookies to ensure you have the best browsing experience on our website. By using our
Got It !
site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
https://www.geeksforgeeks.org/getppid-getpid-linux/ 3/4
10/10/2020 getppid() and getpid() in Linux - GeeksforGeeks
Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Load Comments
Company Learn
About Us Algorithms
Careers Data Structures
Privacy Policy Languages
Contact Us CS Subjects
Video Tutorials
Practice Contribute
Courses Write an Article
Company-wise Write Interview Experience
Topic-wise Internships
How to begin? Videos
We use cookies to ensure you have the best browsing experience on our website. By using our
Got It !
site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
https://www.geeksforgeeks.org/getppid-getpid-linux/ 4/4