aboutsummaryrefslogtreecommitdiff
path: root/src/execute_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/execute_cmd.c')
-rw-r--r--src/execute_cmd.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/execute_cmd.c b/src/execute_cmd.c
index 3730d4b..33ba11c 100644
--- a/src/execute_cmd.c
+++ b/src/execute_cmd.c
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/21 13:58:56 by dkaiser #+# #+# */
-/* Updated: 2024/10/21 15:07:37 by dkaiser ### ########.fr */
+/* Updated: 2024/10/22 15:42:17 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,21 +18,10 @@
int execute_cmd(t_cmd *cmd, t_env *env)
{
int result;
- pid_t pid;
+ char *cmd_path;
- pid = fork();
- if (pid < 0)
- return (EXIT_FAILURE);
- if (pid == 0)
- {
- result = execve(cmd->args[0], cmd->args, env_to_strlst(env));
- exit(result);
- }
- else
- {
- // only wait if cmd is on rightmost side of pipe?
- // so in cmd1 | cmd2 | cmd3 | cmd4 only wait for cmd4
- waitpid(pid, &result, 0);
- }
+ cmd_path = get_cmd_path(cmd->args[0], env);
+ cmd->args[0] = cmd_path;
+ result = execve(cmd->args[0], cmd->args, env_to_strlst(env));
return (result);
}