Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benoit
minishell
Commits
595eaa04
Commit
595eaa04
authored
Jan 22, 2021
by
abenoit
Browse files
fix ret value for external commands and fix leaks in command path
parent
8e08463c
Changes
4
Hide whitespace changes
Inline
Side-by-side
?
deleted
100644 → 0
View file @
8e08463c
$
src/execution/launch_command.c
View file @
595eaa04
...
...
@@ -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
);
...
...
src/ft_exit.c
View file @
595eaa04
...
...
@@ -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
));
...
...
src/main.c
View file @
595eaa04
...
...
@@ -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
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment