Compare commits

..

No commits in common. "cdfa81328b0d62fe6699746fdd5755fc9a4049b3" and "13e455cbf416436a889715c7d87301bebebc1228" have entirely different histories.

2 changed files with 9 additions and 11 deletions

12
main.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */ /* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
/* Updated: 2023/03/30 13:12:41 by cchauvet ### ########.fr */ /* Updated: 2023/03/30 12:41:52 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -43,17 +43,17 @@ static char *ft_get_user_input(void)
static void ft_cmds_waiter(t_data *data) static void ft_cmds_waiter(t_data *data)
{ {
t_list *current; t_list *current;
t_cmd *cmd; t_cmd *content;
int exit_status; int exit_status;
current = *data->cmds; current = *data->cmds;
while (current != NULL) while (current != NULL)
{ {
cmd = current->content; content = current->content;
if (cmd->executable != NULL && cmd->own_cmd == 0 if (content->executable != NULL && content->own_cmd == 0
&& cmd->pid != -1 && cmd->fd_in[0] != -2 && cmd->fd_out[0] != -2) && content->pid != -1 && content->fd_in[0] != -2 && content->fd_out[0] != -2)
{ {
waitpid(cmd->pid, &exit_status, 0); waitpid(content->pid, &exit_status, 0);
if (WIFSIGNALED(exit_status)) if (WIFSIGNALED(exit_status))
{ {
if (WTERMSIG(exit_status) == SIGKILL) if (WTERMSIG(exit_status) == SIGKILL)

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 17:36:11 by cchauvet #+# #+# */ /* Created: 2023/02/15 17:36:11 by cchauvet #+# #+# */
/* Updated: 2023/03/30 13:26:31 by cchauvet ### ########.fr */ /* Updated: 2023/02/15 17:41:13 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -54,8 +54,7 @@ int ft_file_is_writable(t_data *data, const char *path)
ft_eprintf("minishell: %s: Permission denied\n", path); ft_eprintf("minishell: %s: Permission denied\n", path);
return (0); return (0);
} }
close(fd); return (fd);
return (1);
} }
int ft_file_is_appendable(t_data *data, const char *path) int ft_file_is_appendable(t_data *data, const char *path)
@ -77,6 +76,5 @@ int ft_file_is_appendable(t_data *data, const char *path)
ft_eprintf("minishell: %s: Permission denied\n", path); ft_eprintf("minishell: %s: Permission denied\n", path);
return (0); return (0);
} }
close(fd); return (fd);
return (1);
} }