Tuesday 21 June 2016

what is process ID or PID of process in linux

Before discussing about What is process ID or PID of process in linux? Firstly, we should know that in linux, every running task is known as the 'process'.
And these processes are scheduled among different processors
by a program called as 'scheduler' which plays important role in process scheduling.





What is process ID or PID of process in linux

And each process is assigned a unique ID so that they can't be merged.
And this ID is known as process ID or in short PID.

Now let's learn how to print the PID of any running process.
We're going to use C program for this.


Let's start with simple example
  1. #include<stdio.h>
  2. #include<sys/types.h>
  3. int main()
  4. {
  5. printf("Process ID=%d\n",getpid());
  6. return 0;
  7. }
Here, getpid() function is the library function which returns the PID of the calling process
(Here, printf  is the calling process).

Mine output is: 
Process  ID=5739
What is process ID or PID of process in linux

Now, whenever program is terminated, new process ID is assigned to printf when it is created again.
So after executing this program again
The output is:   Process  ID=5745
Hence we always get different results when we execute the program.


Now we see PID of parent process also
  1. #include<stdio.h>
  2. #include<sys/types.h>
  3. int main()
  4. {
  5. printf("Process ID=%d\n",getpid());
  6. printf("Parent process's PID=%d",getppid());
  7. return 0;
  8. }
Here, getppid() function is the library function which returns the PID of the parent process
(Here, shell process  is the parent process).

What is process ID of process in linux

Mine Output is:
Process ID=6677
Parent process's PID =3832

Now after again running the program, the output is:
Process ID=6678
Parent process's ID =3832
Here, we can easily see that Parent process's PID isn't changed

4 comments:

  1. Selling USA FRESH SSN Leads/Fullz, along with Driving License/ID Number with good connectivity.

    **Price for One SSN lead 2$**

    All SSN's are Tested & Verified. Fresh spammed data.

    **DETAILS IN LEADS/FULLZ**

    ->FULL NAME
    ->SSN
    ->DATE OF BIRTH
    ->DRIVING LICENSE NUMBER
    ->ADDRESS WITH ZIP
    ->PHONE NUMBER, EMAIL
    ->EMPLOYEE DETAILS

    ->Bulk order negotiable
    ->Hope for the long term business
    ->You can asked for specific states too

    **Contact 24/7**

    Whatsapp > +923172721122

    Email > leads.sellers1212@gmail.com

    Telegram > @leadsupplier

    ICQ > 752822040

    ReplyDelete
  2. Are you interested in the service of a hacker to get into a phone, facebook account, snapchat, Instagram, yahoo, Whatsapp, get verified on any social network account, increase your followers by any amount, bank wire and bank transfer. Contact him on hackintechnology@gmail.com +12132951376(WHATSAPP)

    ReplyDelete
  3. Do you need to increase your credit score?
    Do you intend to upgrade your school grade?
    Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
    Do you need any information concerning any database.
    Do you need to retrieve deleted files?
    Do you need to clear your criminal records or DMV?
    Do you want to remove any site or link from any blog?
    you should contact this hacker, he is reliable and good at the hack jobs..
    contact : cybergoldenhacker at gmail dot com

    ReplyDelete
  4. Selling USA FRESH SSN Leads/Fullz, along with Driving License/ID Number with good connectivity.

    **PRICE 2$ FOR EACH LEAD/FULLZ**

    All Leads are Tested & Verified.
    Fresh spammed data of USA Credit Bureau
    Good credit Scores, 700 minimum scores.

    **DETAILS IN EACH LEADS/FULLZ**

    ->FULL NAME
    ->SSN
    ->DATE OF BIRTH
    ->DRIVING LICENSE NUMBER WITH EXPIRY DATE
    ->ADDRESS WITH ZIP
    ->PHONE NUMBER, EMAIL, I.P ADDRESS
    ->EMPLOYEE DETAILS
    ->REALTIONSHIP DETAILS
    ->MORTGAGE INFO
    ->BANK ACCOUNT DETAILS

    ->Bulk order will be negotiable
    ->Minimum buy 25 to 30 leads/fullz
    ->Hope for the long term business
    ->You can asked for specific states/zips too
    ->Serous buyer will be warmly welcome

    **Contact 24/7**

    Email > leads.sellers1212@gmail.com

    Telegram > @leadsupplier

    ICQ > 752822040

    ReplyDelete