Commit 838a6616 authored by abenoit's avatar abenoit
Browse files

child process error exit fix

parent 6af9886e
......@@ -75,6 +75,7 @@ typedef struct s_command
typedef struct s_xe
{
pid_t gpid;
int child;
int backup_stdin;
int backup_stdout;
int stat_loc;
......
6
\ No newline at end of file
5
\ No newline at end of file
UID PID PENDING BLOCKED IGNORED CAUGHT STAT TTY TIME COMMAND
1001 2372 0000000000000000 0000000000000002 0000000000384000 0000000188013003 Ss pts/0 0:00 zsh
1001 3722 0000000000000000 0000000000000002 0000000000384000 0000000188013003 Ss pts/1 0:00 zsh
1001 3770 0000000000000000 0000000000000000 0000000000000000 0000000000010002 S+ pts/1 0:16 sh ./test.sh
1001 31878 0000000000000000 0000000000000000 0000000000000000 0000000180005007 D+ pts/0 0:00 git add .
1001 31914 0000000000000000 0000000000000000 0000000000000000 00000001f3d1fef9 R+ pts/1 0:00 ps -s
......@@ -15,5 +15,8 @@ int exec_error(int err_code, t_xe *xe)
xe->stat_loc = 1;
if (err_code == NO_SUCH_FILE)
xe->stat_loc = 127;
return (SUCCESS);
if (xe->child == 1)
return (CLEAN_EXIT);
else
return (SUCCESS);
}
......@@ -59,6 +59,7 @@ static int child_task(char **path, char **args, t_xe *xe)
char *cmd;
int dir_index;
xe->child = 1;
if (ft_strchr(args[0], '/') != NULL)
if (execve(args[0], args, xe->env) == ERROR)
perror("External function error:");
......
......@@ -69,6 +69,7 @@ int exec_env_init(t_xe *xe, char **env_source)
int ret;
xe->env = dup_str_array(env_source);
xe->child = 0;
if (xe->env == NULL)
ret = MALLOC_ERR;
shlvl = get_var_value(xe->env, SHLVL_STR, ft_strlen(SHLVL_STR));
......
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