We have an exec that work (only once tho)

This commit is contained in:
Maieul BOYER 2024-08-03 16:35:16 +02:00
parent 8ee24b1bcf
commit 887601bf2b
No known key found for this signature in database
8 changed files with 25 additions and 34 deletions

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/03 16:22:41 by maiboyer #+# #+# */
/* Updated: 2024/08/02 19:11:00 by maiboyer ### ########.fr */
/* Updated: 2024/08/03 16:34:46 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -27,8 +27,6 @@ t_error handle_redirections(t_spawn_info *info, t_process *process);
t_error spawn_process_exec(t_spawn_info info, t_process *process)
{
bool res;
if (info.forked_free)
info.forked_free(info.forked_free_args);
dup2(info.stdin.fd.fd->fd, 0);
@ -40,11 +38,8 @@ t_error spawn_process_exec(t_spawn_info info, t_process *process)
close_fd(info.stdin.fd.fd);
close_fd(info.stdout.fd.fd);
close_fd(info.stderr.fd.fd);
if (!vec_str_any(&info.arguments, _find_null, &res) && res)
vec_str_push(&info.arguments, NULL);
res = false;
if (!vec_str_any(&info.environement, _find_null, &res) && res)
vec_str_push(&info.environement, NULL);
vec_str_push(&info.arguments, NULL);
vec_str_push(&info.environement, NULL);
execve(info.binary_path, info.arguments.buffer, info.environement.buffer);
return (NO_ERROR);
}

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/17 15:56:59 by maiboyer #+# #+# */
/* Updated: 2024/07/30 16:11:22 by rparodi ### ########.fr */
/* Updated: 2024/08/03 16:33:53 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,7 +31,7 @@ t_error str_split(t_const_str str, t_const_str chr, t_vec_str *out)
while (str[idx] != '\0' && str_find_chr(chr, str[idx]) != NULL)
idx++;
while (str[idx] != '\0' && str_find_chr(chr, str[idx]) == NULL)
string_push_char(&buf, str[idx]);
string_push_char(&buf, str[idx++]);
if (buf.len != 0)
{
vec_str_push(&ret, buf.buf);