Good evening,
i would like to ask you sthg related to finding the parent's id of a process.
I need my C program to output e.g. 48 : 47 --> - 34 --> - 2 --> - 0
where 48 is the id of the process,47 is the parent's id,-34 is the parent's id of the parent of the process etc.
I do :
What shall i do in order to output the parent's,parent id and the other ids?Code:#include <unistd.h> #include <sys/types.h> #include <errno.h> #include <stdio.h> #include <sys/wait.h> #include <stdlib.h> int main() { printf("The process id is %d\n",getpid()); printf("The processes parent's id is %d\n",getppid()); }
Thanks,in advance!