43 char *builtin_commands[7];
46 builtin_commands[0] =
"cd";
47 builtin_commands[1] =
"echo";
48 builtin_commands[2] =
"env";
49 builtin_commands[3] =
"exit";
50 builtin_commands[4] =
"export";
51 builtin_commands[5] =
"pwd";
52 builtin_commands[6] =
"unset";
61 while (++i <
sizeof(builtin_commands) /
sizeof(
char *))
63 return ((*builtin_functions[i])(data));
105 waitpid(pid, &exit, 0);
106 if (WIFSIGNALED(exit) && WTERMSIG(exit) == SIGQUIT)
108 return (WEXITSTATUS(exit));
113 if (exec_path == NULL)
115 ft_putstr_fd(
"maxishell: command not found\n", STDERR_FILENO);
121 arguments or environment\n", STDERR_FILENO);
126 ft_putstr_fd(
"maxishell: command not found\n", STDERR_FILENO);
135 ft_memset(&a, 0,
sizeof(
struct sigaction));
136 sigemptyset(&a.sa_mask);
137 a.sa_handler = SIG_DFL;
139 sigaction(SIGQUIT, &a, NULL);
int builtin_exit(t_ms_data *data)
int builtin_pwd(t_ms_data *data)
int builtin_unset(t_ms_data *data)
int builtin_cd(t_ms_data *data)
int builtin_echo(t_ms_data *data)
int builtin_env(t_ms_data *data)
int builtin_export(t_ms_data *data)
char ** env_to_array(t_env *envp)
char * ft_find_path(char *cmd, t_env *envp)
function find the full path of the executed command
void handle_std_io(int *std_io, int std_fileno)
void close_fds(int in, int out)
close two file descriptors
static void signal_handler(void)
static void handle_exec_errors(char *exec_path, t_ms_data *data)
static int new_process(t_ms_data *data)
static void child_process(t_ms_data *data)
executes a new process
int execute(t_ms_data *data)
execute distribution function
int ft_printf(const char *format,...)
int ft_strcmp(const char *s1, const char *s2)
void * ft_memset(void *s, int c, size_t n)
int ft_strncmp(const char *s1, const char *s2, size_t n)
void ft_putstr_fd(char *s, int fd)
char * ft_strdup(const char *s)