fix?: close stdin and stdout at the end of child process

This commit is contained in:
Renge 2022-04-16 11:10:15 -04:00
parent 0c150e1f9d
commit 5f3abb14e8

View File

@ -359,6 +359,8 @@ int jobs_run(PIPELINE *pline) {
} }
free(args); free(args);
int exit_code = errno; int exit_code = errno;
close(STDIN_FILENO);
close(STDOUT_FILENO);
exit(exit_code); exit(exit_code);
} }
} }
@ -385,6 +387,8 @@ int jobs_run(PIPELINE *pline) {
if (WIFEXITED(status)) if (WIFEXITED(status))
exit_code = WEXITSTATUS(status); exit_code = WEXITSTATUS(status);
} }
close(STDIN_FILENO);
close(STDOUT_FILENO);
exit(exit_code); exit(exit_code);
} }