question: for the below program
i just printed the value for pid, child pid and parent pid
why does it give me 6 values? i assume ppid is 28086
but can't figure out why there are 5 values printed instead of just two!
can someone comment on that!
#include<stdio.h> #define DIM 8
int main()
{
int pid, i, ans;
int arr[DIM] = {1,2,3,4,5,6,7,8};
perderabo,
yeah it makes sense that both child and process will execute the 3 staments, giving 6 results.
is the output in order of child,child,child,parent,parent,parent
now can u correct me if i m wrong here
0 - is the return int value that is always passed to the child to the child
this one is executed by printf("%d\n",pid);
28873 - is the pid of the child which is contained in the parent
this also executed by printf("%d\n",getpid());
28872 - is the pid of the parent
it is executed by printf("%d\n",getppid());
now running for parent
28873 - is the pid of the child
it is executed by printf("%d\n",pid);
28872 - is the pid of the parent that makes the child here
it is executed by printf("%d\n",getpid());
28086 - is the pid of the shell running this program
it is executed by printf("%d\n",getppid());
arrrrrrrrgh:confused: i am confuuuuuuuused!
Hope i got that right
Sorry i am slow and ask too many questions:(