]> git.dkaiser.de - 42/minishell.git/commitdiff
yippienorm and change open error and change of wife
authorChristopher Uhlig <chuhlig@3-H-8.42heilbronn.de>
Mon, 20 Jan 2025 19:10:11 +0000 (20:10 +0100)
committerChristopher Uhlig <chuhlig@3-H-8.42heilbronn.de>
Mon, 20 Jan 2025 19:10:11 +0000 (20:10 +0100)
src/execute_cmd.c
src/interpreter.c

index ab430326ac0fa411d55757ef12e0b9ec5a1c9f45..1438f9cc30d1b5e0a8f97c720abb70cbdf3e3b25 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: chuhlig <chuhlig@student.42.fr>            +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/12/17 19:21:35 by chuhlig           #+#    #+#             */
-/*   Updated: 2025/01/20 15:43:41 by chuhlig          ###   ########.fr       */
+/*   Updated: 2025/01/20 20:04:31 by chuhlig          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -51,8 +51,8 @@ int   execute_cmd(t_cmd *cmd, t_env **env)
 
        original_std[1] = dup(STDOUT_FILENO);
        original_std[0] = dup(STDIN_FILENO);
-       result = create_files(cmd->create_files);
-       if (result != EXIT_SUCCESS || handle_redirections(cmd->redirs) == -1)
+       create_files(cmd->create_files);
+       if (handle_redirections(cmd->redirs) == -1)
        {
                establish_pipeline(original_std[0], original_std[1]);
                return (EXIT_FAILURE);
@@ -63,8 +63,6 @@ int   execute_cmd(t_cmd *cmd, t_env **env)
                establish_pipeline(original_std[0], original_std[1]);
                return (result);
        }
-       if (result != EXIT_SUCCESS)
-               return (result);
        return (exec_cmd(cmd, env, original_std, EXIT_SUCCESS));
 }
 
@@ -102,5 +100,5 @@ static int  exec_cmd(t_cmd *cmd, t_env **env, int original_std[2], int result)
        }
        waitpid(pid, &status, 0);
        establish_pipeline(original_std[0], original_std[1]);
-       return (WEXITSTATUS(status));
+       return ((status >> 8) & 255);
 }
index 44f4b950fd320821f7a5259d8f36eb79b484b9d1..9cd52921383e4e460e285906d934d7997d4006f4 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: chuhlig <chuhlig@student.42.fr>            +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/12/17 19:15:49 by chuhlig           #+#    #+#             */
-/*   Updated: 2025/01/20 19:12:49 by chuhlig          ###   ########.fr       */
+/*   Updated: 2025/01/20 20:07:11 by chuhlig          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -21,7 +21,7 @@ int   open_file(char *path, int flags, int mode)
 
        fd = open(path, flags, mode);
        if (fd < 0)
-               perror("open");
+               perror(path);
        return (fd);
 }