Compare commits

...

3 Commits

Author SHA1 Message Date
Camille Chauvet
cdfa81328b fix: file verif cause non close fd 2023-03-30 13:27:23 +02:00
Camille Chauvet
bb00de527a Merge branch 'master' of git.chauvet.pro:starnakin/42_minishell 2023-03-30 13:13:10 +02:00
Camille Chauvet
7e77c4fe48 clean: norm 2023-03-30 13:12:56 +02:00
2 changed files with 11 additions and 9 deletions

12
main.c
View File

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

View File

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