Skip to content

Commit 1caf628

Browse files
Merge pull request #258 from jeremie1112/master
added a program to get all PIDs that is used by parent and child in a…
2 parents f06964e + a1a06dd commit 1caf628

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

getPIDs.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <sys/types.h>
2+
#include <unistd.h>
3+
#include <stdio.h>
4+
5+
void main(){
6+
pid_t pid; //variable to store process id
7+
pid_t ppid; //variable to store parent process id
8+
9+
sleep(5);
10+
11+
pid = getpid(); // returns pid
12+
ppid = getppid(); //returns parent pid
13+
14+
printf("The process id is : %d\n" , pid);
15+
printf("The parent of process id is : %d\n" , ppid);
16+
}

0 commit comments

Comments
 (0)