42_minishell/execution.c

35 lines
569 B
C
Raw Normal View History

2023-02-09 12:47:05 -05:00
#include "libftx/libftx.h"
#include "minishell.h"
#include <unistd.h>
int main(int ac, char **av, char **env)
{
}
2023-02-14 01:21:24 -05:00
/* char *ft_get_executable_path(t_data *data, char *executable) */
/* { */
/* if (ft_strcmp(executable, "env") == 0) */
/* return (ft_strjoin("", executable)); */
/* else */
/* return */
/* } */
2023-02-09 12:47:05 -05:00
2023-02-14 01:21:24 -05:00
int ft_excutor(t_cmd *cmd)
2023-02-09 12:47:05 -05:00
{
int pid;
pid = fork();
if (pid == -1)
return (1);
if (pid == 0)
{
2023-02-14 01:21:24 -05:00
dup2(cmd->fd_out, 1);
dup2(cmd->fd_in, 0);
//TODO ADD ENV VARIABLES
execve(cmd->executable, cmd->args, NULL);
2023-02-09 12:47:05 -05:00
}
else
waitpid(pid);
}