linux - how to find out when the code reads parent or child process and how do they communicate in C -
i have shell program fork created , used 2 if else statements separate parent , child process.
my sample program here , got few questions
while(true) { /* read command line input */ x = fork(); if( x > 0) { wait(&status); } else { /* run exec() command */ } }
from above code statement execute first after fork , how parent know child exec command executed or unsuccessfully , when parent stop wait , in condition , how. , how wait(&status) code work.
help appreciated.
this should give better idea of how fork() system call works.
Comments
Post a Comment