fixed close() of c->script_fd

This commit is contained in:
lperrey
2021-12-21 12:22:25 +01:00
parent e4c4589d3c
commit 5a39470290

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */ /* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/10 23:53:17 by lperrey #+# #+# */ /* Created: 2021/10/10 23:53:17 by lperrey #+# #+# */
/* Updated: 2021/12/20 22:47:26 by lperrey ### ########.fr */ /* Updated: 2021/12/21 12:14:43 by lperrey ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -22,9 +22,12 @@ int exit_free(t_all *c, int exit_status)
free_pipeline(&c->pipeline); free_pipeline(&c->pipeline);
if (c->script_fd) if (c->script_fd)
{ {
gnl(c->script_fd, NULL, 1); if (c->script_fd > 0)
if (close(c->script_fd) == -1) {
perror("close()"); gnl(c->script_fd, NULL, 1);
if (close(c->script_fd) == -1)
perror("close()");
}
} }
else if (!isatty(STDIN_FILENO)) else if (!isatty(STDIN_FILENO))
gnl(STDIN_FILENO, NULL, 1); gnl(STDIN_FILENO, NULL, 1);