J
just_james
Guest
Hello everyone,
I have to write in c a program which return an exit codes of three child processes. I know that wait() function can do that (writes to the ver so i wrote something like this:
It doesn't work, could someone help me with that ?
I have to write in c a program which return an exit codes of three child processes. I know that wait() function can do that (writes to the ver so i wrote something like this:
Code:
#include <stdio.h>
#include <sys/wait.h>
int main(void)
{
int pid1,pid2,pid_from_wait,status,status2;
pid1=fork();
if( pid1 != 0 )
{
pid_from_wait = wait(&status);
printf("Child1 %d ended up with code %d \n",
pid_from_wait, status);
pid2=fork();
if( pid2 != 0 );
{
wait(&status2);
printf("Child2 %d ended up with code %d \n", getpid(),
status2);
}
else
printf("I'm child 2");
}
else
printf("I'm child0");
return 0;
}
It doesn't work, could someone help me with that ?