In order to know if wait() has worked, will it be correct to check it like the following? In theory, if wait() does not fail, should return to the parent process the ended child pid, otherwise parent pid will be 1, right?
switch (process = fork())
{
case -1:
// Fork fail
perror("Fork failed");
exit(EXIT_FAILURE);
case 0:
//Child process
HERE CODE DOES SOMETHING
exit(EXIT_SUCCESS);
default:
//Parent process
pid=wait(&status);
if(pid==1){
perror("Wait failed");
}else{
exit(EXIT_SUCCESS);
}
}