fixed: splitting
This commit is contained in:
parent
ca8e484183
commit
135a6429ee
14 changed files with 117 additions and 66 deletions
|
|
@ -6,21 +6,21 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/14 12:30:09 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/10/13 17:59:35 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/10/14 15:07:42 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/env.h"
|
||||
#include "exec/_run_ast.h"
|
||||
#include "line/line.h"
|
||||
#include "me/fs/fs.h"
|
||||
#include "me/os/os.h"
|
||||
#include "me/printf/printf.h"
|
||||
#include "me/str/str.h"
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "line/line.h"
|
||||
#include "me/types.h"
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
t_error _redirection_fd(\
|
||||
t_spawn_info *info, t_state *state, t_ast_node red);
|
||||
|
|
@ -55,12 +55,20 @@ t_error _setup_redirection(\
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
static t_error _err_cmd(t_str bpath)
|
||||
{
|
||||
me_eprintf("failed to execute %s\n", bpath);
|
||||
str_free(bpath);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
t_error _spawn_cmd_and_run_end(\
|
||||
t_spawn_info info, t_state *state, \
|
||||
t_cmd_pipe cmd_pipe, t_command_result *out)
|
||||
{
|
||||
struct s_ffree_state ffree;
|
||||
int status;
|
||||
t_str bpath;
|
||||
|
||||
status = 0;
|
||||
ffree = (struct s_ffree_state){.state = state, .cmd_pipe = cmd_pipe};
|
||||
|
|
@ -68,8 +76,10 @@ t_error _spawn_cmd_and_run_end(\
|
|||
info.forked_free = (void (*)(void *))_ffree_func;
|
||||
signal(SIGINT, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
bpath = str_clone(info.binary_path);
|
||||
if (spawn_process(info, &out->process))
|
||||
return (close_fd(cmd_pipe.input), out->exit = 127, ERROR);
|
||||
return (close_fd(cmd_pipe.input), out->exit = 127, _err_cmd(bpath));
|
||||
str_free(bpath);
|
||||
if (cmd_pipe.create_output || cmd_pipe.input != NULL)
|
||||
return (out->exit = -1, NO_ERROR);
|
||||
if (waitpid(out->process.pid, &status, 0) == -1 && errno != ECHILD)
|
||||
|
|
@ -88,8 +98,6 @@ t_error _spawn_cmd_and_run(t_vec_str args, t_redirections redirs,
|
|||
t_spawn_info info;
|
||||
|
||||
info = (t_spawn_info){};
|
||||
for (t_usize i = 0; i < args.len; i++)
|
||||
printf("args[%zu] = %s\n", i, args.buffer[i]);
|
||||
if (_setup_redirection(&info, state, redirs.cmd_pipe, &redirs.redirections))
|
||||
return (ERROR);
|
||||
redirs.redirections.len = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue