useless code ?
This commit is contained in:
parent
209bdb86a6
commit
262373aab7
16
minishell.c
16
minishell.c
|
@ -38,7 +38,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// gestion de SIGCHLD
|
// gestion de SIGCHLD
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_flags = SA_SIGINFO; //| SA_RESTART;
|
action.sa_flags = SA_SIGINFO | SA_RESTART;
|
||||||
action.sa_handler = handler_print;
|
action.sa_handler = handler_print;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGCHLD, &action, NULL);
|
sigaction(SIGCHLD, &action, NULL);
|
||||||
|
@ -110,23 +110,13 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // on attend le fils, si foreground
|
{ // on attend le fils, si foreground
|
||||||
jmp_buf env;
|
|
||||||
setjmp(env); // sauvegarde pour un jump
|
|
||||||
|
|
||||||
int codeTerm;
|
int codeTerm;
|
||||||
pid_t idFils = waitpid(pidFils, &codeTerm, 0); // on attend la fin de l'exec du fils
|
pid_t idFils = waitpid(pidFils, &codeTerm, 0); // on attend la fin de l'exec du fils
|
||||||
|
|
||||||
if (idFils == -1)
|
if (idFils == -1)
|
||||||
{ // si le wait fail
|
{ // si le wait fail
|
||||||
if (errno == 4)
|
fprintf(stderr, "ERROR: waiting for %d failed, (%d) %s\n", codeTerm, errno, strerror(errno));
|
||||||
{
|
exit(errno);
|
||||||
longjmp(env, 1); // si interruption du wait, on jump
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "ERROR: waiting for %d failed, (%d) %s\n", codeTerm, errno, strerror(errno));
|
|
||||||
exit(errno);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codeTerm)
|
if (codeTerm)
|
||||||
|
|
Loading…
Reference in a new issue