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
955b71f6
Commit
955b71f6
authored
Feb 02, 2021
by
abenoit
Browse files
execve error return
parent
6c9aec68
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ft_error.c
View file @
955b71f6
...
...
@@ -60,20 +60,22 @@ static int err_output(int err_code)
return
(
SUCCESS
);
}
int
clean_and_exit
(
int
ret
,
t_xe
*
xe
)
int
clean_and_exit
(
int
err_code
,
t_xe
*
xe
)
{
if
(
ret
==
ARG_ERR
)
int
ret
;
if
(
err_code
==
ARG_ERR
)
{
if
(
ft_putstr_fd
(
"Minishell takes no argument"
,
STDERR_FILENO
)
!=
WRITE_SUCCESS
)
ft_error
(
WRITE_ERR
,
xe
);
// possible?
}
if
(
ret
<
CHILD_EXIT
)
if
(
err_code
<
CHILD_EXIT
)
ret
=
EXIT_SUCCESS
;
else
{
if
(
ret
==
CHILD_ERROR
)
if
(
err_code
==
CHILD_ERROR
)
{
ft_putstr_fd
(
"External function error:"
,
STDERR_FILENO
);
// -> strerror
ft_putstr_fd
(
"External function error:
"
,
STDERR_FILENO
);
// -> strerror
ft_putendl_fd
(
strerror
(
errno
),
STDERR_FILENO
);
// strerror error?
}
ret
=
(
xe
->
stat_loc
);
...
...
@@ -82,8 +84,13 @@ int clean_and_exit(int ret, t_xe *xe)
free_str_array
(
xe
->
env
);
// besoin de free?
free
(
xe
);
if
(
isatty
(
STDIN_FILENO
))
// temp pour le testeur
if
(
ft_putstr_fd
(
"exit
\n
"
,
STDOUT_FILENO
)
!=
WRITE_SUCCESS
)
return
(
WRITE_ERR
);
// possible?
{
if
(
err_code
==
CLEAN_EXIT
)
{
if
(
ft_putstr_fd
(
"exit
\n
"
,
STDOUT_FILENO
)
!=
WRITE_SUCCESS
)
return
(
WRITE_ERR
);
// possible?
}
}
exit
(
ret
);
}
...
...
Write
Preview
Markdown
is supported
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