From 596c61f7088db86dc69d5657f6b7c1fff4af0e8e Mon Sep 17 00:00:00 2001 From: jeremie1112 Date: Sun, 3 Oct 2021 10:35:05 +0400 Subject: [PATCH] added a program that shows PIDs of parent and child process in a system --- getPIDs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 getPIDs.c diff --git a/getPIDs.c b/getPIDs.c new file mode 100644 index 0000000..518ae2a --- /dev/null +++ b/getPIDs.c @@ -0,0 +1,17 @@ +#include +#include +#include + +void main(){ + pid_t pid; //variable to store process id + pid_t ppid; //variable to store parent process id + + sleep(5); + + pid = getpid(); // returns pid + ppid = getppid(); //returns parent pid + + printf("The process id is : %d\n" , pid); + printf("The parent of process id is : %d\n" , ppid); +} +