Commit 595eaa04 authored by abenoit's avatar abenoit
Browse files

fix ret value for external commands and fix leaks in command path

parent 8e08463c
......@@ -84,10 +84,10 @@ static int launch_ext(char **args, t_xe *xe)
char *tmp;
char **path;
ret = SUCCESS;
ret = get_var_pos(xe->env, "PATH", 4); // and with PATH unset?
if (ret == -1)
return (NO_SUCH_FILE);
ret = SUCCESS;
tmp = get_var_value(xe->env, "PATH", 4); // and with PATH unset?
if (tmp == NULL)
return (M_ERROR);
......@@ -100,13 +100,16 @@ static int launch_ext(char **args, t_xe *xe)
if (pid == 0)
{
ret = child_task(path, args, xe);
free_str_array(path);
}
else
{
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
waitpid(pid, &xe->stat_loc, 0); // return value? error?
xe->stat_loc = xe->stat_loc / 256;
free_str_array(path);
if (xe->stat_loc > 256)
xe->stat_loc = xe->stat_loc / 256;
signal_handler();
}
return (ret);
......
......@@ -78,7 +78,9 @@ static int err_output(int err_code)
int ft_error(int ret, t_xe *xe)
{
if (ret >= SQUOTE_MISSING)// temp
if (ret == CLEAN_EXIT)
return (ft_exit(ret, xe));
else if (ret >= SQUOTE_MISSING)// temp
return (parsing_error(ret - 9, xe));
else if (ret >= HOME_NOT_SET)
return (exec_error(ret, xe));
......
......@@ -56,9 +56,9 @@ static int main_loop(t_xe *xe)
return (ft_error(ret, xe));
ret = handle_execution(xe, STDIN_FILENO, 0);
//printf("ret = %d\n", ret);
free(line);
if (ret != SUCCESS)
return (ft_error(ret, xe));
free(line);
}
return (ret);
}
......
Supports Markdown
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