Process Identification in Linux – Tutorial & Example

In this article we will discuss, how to differentiate and identify each process in linux.

Process ID

Each process in Linux has a unique id and has a parent.  We can get the process id of a running process and its parent’s process id using following functions,

pid_t getpid()
pid_t getppid()

File to be included for them is <unistd.h>

Let’s see an example,

#include <iostream>
#include <unistd.h>

int main()

  pid_t processId = getpid();
  pid_t parentProcessId = getppid();

  std::cout<<"Process ID : "<<processId<<std::endl;
  std::cout<<"Parent Process ID : "<<parentProcessId<<std::endl;
  return 0;


Process ID : 3825
Parent Process ID : 3560

To check the process id and parent process id of all running process, use following command,

ps -fe

Output will contains many rows with following columns i.e

varun 3223 1880 0 23:10 ? 00:00:02 /usr/lib/chromium-browser/chro
varun 3250 1880 0 23:10 ? 00:00:01 /usr/lib/chromium-browser/chro

[showads ad=inside_post]


Here PID represents process id and PPID represents Parent Process Id

What is an Orphan Process

Every process has a parent process.
If a parent process terminates then all its children process become orphan processes. As soon as a process becomes orphan, the init process becomes their parent.

Process ID of init process is 1.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top