Commit 43b453f6 authored by abenoit's avatar abenoit
Browse files

execve error exit

parent 8fce9081
......@@ -21,6 +21,7 @@ enum e_retcode
INVALID_PWD_PATH,
INVALID_PATH_DIR,
FD_ERROR,
EXT_CMD_ERROR,
_EXEC_ERROR_,
AMBIG_REDIR,
NO_SUCH_FILE,
......
......@@ -51,7 +51,7 @@ static int exec_cmd(char *cmd, char **args, t_xe *xe)
{
xe->flags += CHILD_ERROR;
xe->flags -= RUN;
return (CLEAN_EXIT);
return (EXT_CMD_ERROR);
}
else
{
......
......@@ -37,12 +37,11 @@ int exec_error(int err_code, t_xe *xe)
if (err_code == NO_SUCH_FILE)
xe->stat_loc = 127;
if (xe->flags & EXEC_PIPE)
return (CHILD_EXIT);
else
return (SUCCESS);
xe->flags += CHILD_EXIT;
return (SUCCESS);
}
static int err_output(int err_code)
static int err_output(int err_code, t_xe *xe)
{
const char *err_msg[] = {
"Memory allocation failure",
......@@ -52,12 +51,16 @@ static int err_output(int err_code)
"cd: cannot set variable PWD",
"pwd: cannot get current directory path",
"Error reading a directory in PATH",
"fd"}; // fd?
"fd",
"external command error"}; // fd?
(void)xe;
ft_putstr_fd("error: ", STDERR_FILENO);
ft_putstr_fd(err_msg[err_code - _ERRNO_MSG_ -1], STDERR_FILENO);
ft_putstr_fd(": ", STDERR_FILENO); // besoin de faire comme perror?
ft_putendl_fd(strerror(errno), STDERR_FILENO); // strerror error?
if (err_code == EXT_CMD_ERROR)
exit (2);
return (SUCCESS);
}
......@@ -116,7 +119,7 @@ int ft_error(int ret, t_xe *xe)
else if (ret > _EXEC_ERROR_)
return (exec_error(ret, xe));
else if (ret > _ERRNO_MSG_)
err_output(ret);
err_output(ret, xe);
else if (ret > _EXIT_CODE_)
return (clean_and_exit(ret, xe));
else if (ret != SUCCESS) // temp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment