Another question:
look at this simple code
Code:
#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
int main(){
int pid,status;
switch (pid = fork()) {
case 0: /* child process */
printf("Hello I am the child running :D, and my pid is: %d\n",getpid());
exit(1);
break;
case -1: /* parent process -- fork() was unsuccessful, no child */
printf("Fork failed!");
break;
default: /* parent process -- successful */
printf("Hello I am the parent, the big boss and my pid is: %d\nI am waiting for my child to return...\n",getpid());
pid_t rpid = wait(&status);
printf("We got a child returning with code: %i , and pid : %d !\n",status, rpid);
break;
}
}
i get output:
Code:
Hello I am the child running :D, and my pid is: 26860
Hello I am the parent, the big boss and my pid is: 26859
I am waiting for my child to return...
We got a child returning with code: 256 , and pid : 26860 !
Why is the value of status 256?
i sent an exit code of 1 ...
( cnat look up the api my man is busted on this system