update: still smth to fix

This commit is contained in:
Maieul BOYER 2024-10-13 18:01:30 +02:00
parent d97efa87a7
commit 7e16ea3fe0
No known key found for this signature in database
4 changed files with 16 additions and 12 deletions

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/14 12:30:09 by maiboyer #+# #+# */ /* Created: 2024/09/14 12:30:09 by maiboyer #+# #+# */
/* Updated: 2024/10/13 17:32:14 by maiboyer ### ########.fr */ /* Updated: 2024/10/13 17:59:35 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -62,6 +62,7 @@ t_error _spawn_cmd_and_run_end(\
struct s_ffree_state ffree; struct s_ffree_state ffree;
int status; int status;
status = 0;
ffree = (struct s_ffree_state){.state = state, .cmd_pipe = cmd_pipe}; ffree = (struct s_ffree_state){.state = state, .cmd_pipe = cmd_pipe};
info.forked_free_args = &ffree; info.forked_free_args = &ffree;
info.forked_free = (void (*)(void *))_ffree_func; info.forked_free = (void (*)(void *))_ffree_func;
@ -71,7 +72,7 @@ t_error _spawn_cmd_and_run_end(\
return (close_fd(cmd_pipe.input), out->exit = 127, ERROR); return (close_fd(cmd_pipe.input), out->exit = 127, ERROR);
if (cmd_pipe.create_output || cmd_pipe.input != NULL) if (cmd_pipe.create_output || cmd_pipe.input != NULL)
return (out->exit = -1, NO_ERROR); return (out->exit = -1, NO_ERROR);
if (waitpid(out->process.pid, &status, 0) == -1 && errno != ESRCH) if (waitpid(out->process.pid, &status, 0) == -1 && errno != ECHILD)
return (ERROR); return (ERROR);
if (WIFEXITED(status)) if (WIFEXITED(status))
out->exit = WEXITSTATUS(status); out->exit = WEXITSTATUS(status);

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/14 12:32:37 by maiboyer #+# #+# */ /* Created: 2024/09/14 12:32:37 by maiboyer #+# #+# */
/* Updated: 2024/10/13 13:58:31 by maiboyer ### ########.fr */ /* Updated: 2024/10/13 18:01:06 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,6 +14,7 @@
#include "me/vec/vec_ast.h" #include "me/vec/vec_ast.h"
#include "me/vec/vec_pid.h" #include "me/vec/vec_pid.h"
#include <errno.h> #include <errno.h>
#include <stdio.h>
#include <sys/wait.h> #include <sys/wait.h>
t_usize _pipeline_set_vars(\ t_usize _pipeline_set_vars(\
@ -47,9 +48,11 @@ void _wait_pipeline(t_vec_pid pids, t_state *state, t_pipeline_result *out)
if (pids.len != 0) if (pids.len != 0)
{ {
waitpid_status = 0;
while (waitpid(pids.buffer[pids.len - 1], &waitpid_status, 0) < 0 \ while (waitpid(pids.buffer[pids.len - 1], &waitpid_status, 0) < 0 \
&& errno != ESRCH) && errno != ECHILD)
; if (errno == ECHILD)
waitpid_status = 0;
while (waitpid(-1, NULL, 0) != -1) while (waitpid(-1, NULL, 0) != -1)
; ;
if (WIFEXITED(waitpid_status)) if (WIFEXITED(waitpid_status))

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */ /* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
/* Updated: 2024/10/12 17:52:01 by rparodi ### ########.fr */ /* Updated: 2024/10/13 17:55:56 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -94,7 +94,7 @@ t_error parse_str(t_state *state)
if (ts_apply_passes(tokens, &tokens)) if (ts_apply_passes(tokens, &tokens))
return (ERROR); return (ERROR);
if (yard(tokens, &ast)) if (yard(tokens, &ast))
return ((void)printf("failed to ast build\n"), (ERROR)); return (ERROR);
if (ast.len != 1) if (ast.len != 1)
return (ERROR); return (ERROR);
vec_ast_pop(&ast, &state->ast); vec_ast_pop(&ast, &state->ast);

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/02 13:22:14 by maiboyer #+# #+# */ /* Created: 2024/05/02 13:22:14 by maiboyer #+# #+# */
/* Updated: 2024/10/12 17:52:02 by rparodi ### ########.fr */ /* Updated: 2024/10/13 17:56:04 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,9 +16,9 @@
t_error install_signal(void) t_error install_signal(void)
{ {
if (signal(SIGINT, SIG_IGN)) //if (signal(SIGINT, SIG_IGN))
return (ERROR); // return (ERROR);
if (signal(SIGQUIT, SIG_IGN)) //if (signal(SIGQUIT, SIG_IGN))
return (ERROR); // return (ERROR);
return (NO_ERROR); return (NO_ERROR);
} }