update
This commit is contained in:
parent
fa3208e33e
commit
1d4fd27f97
2 changed files with 66 additions and 6 deletions
|
|
@ -6,15 +6,19 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/17 16:42:19 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/18 14:36:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/state.h"
|
||||
#include "ast/ast.h"
|
||||
#include "exec/run.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/os/pipe.h"
|
||||
#include "me/os/process.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_str.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
|
|
@ -28,6 +32,15 @@ struct s_expansion_result
|
|||
t_str str;
|
||||
};
|
||||
|
||||
typedef struct s_command_result t_command_result;
|
||||
|
||||
struct s_command_result
|
||||
{
|
||||
bool is_forked;
|
||||
int subshell_pid;
|
||||
t_process process;
|
||||
};
|
||||
|
||||
#ifdef ERROR
|
||||
# undef ERROR
|
||||
#endif
|
||||
|
|
@ -192,7 +205,7 @@ t_error _handle_expansion_operator(t_ast_expansion *self, t_state *state, t_expa
|
|||
// End Internals funcs
|
||||
|
||||
t_error run_expansion(t_ast_expansion *self, t_state *state, t_expansion_result *out);
|
||||
t_error run_command(t_ast_command *command, t_state *state, void *out);
|
||||
t_error run_command(t_ast_command *command, t_state *state, t_command_result *out);
|
||||
|
||||
t_error run_arithmetic_expansion(t_ast_arithmetic_expansion *arithmetic_expansion, t_state *state, void *out) NOT_DONE;
|
||||
t_error run_case_(t_ast_case *case_, t_state *state, void *out) NOT_DONE;
|
||||
|
|
@ -242,8 +255,20 @@ t_error run_expansion(t_ast_expansion *self, t_state *state, t_expansion_result
|
|||
return (*out = ret, NO_ERROR);
|
||||
}
|
||||
|
||||
t_error run_command(t_ast_command *command, t_state *state, void *out)
|
||||
t_error run_command(t_ast_command *command, t_state *state, t_command_result *out)
|
||||
{
|
||||
t_vec_str args;
|
||||
t_usize i;
|
||||
|
||||
if (command == NULL || state == NULL || out == NULL)
|
||||
return (ERROR);
|
||||
args = vec_str_new(command->cmd_word.len, (void (*)(t_str))mem_free);
|
||||
i = 0;
|
||||
while (i < command->cmd_word.len)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/02 13:22:14 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/09 14:43:30 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/18 14:53:14 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,9 +14,31 @@
|
|||
#include "me/fs/fs.h"
|
||||
#include "me/printf/printf.h"
|
||||
#include "me/types.h"
|
||||
#include "signal.h"
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct s_sig_pending t_sig_pending;
|
||||
struct s_sig_pending
|
||||
{
|
||||
int pending_signal[1024];
|
||||
int pending_signal_data[1024];
|
||||
t_usize length;
|
||||
};
|
||||
|
||||
t_sig_pending *get_sig_pending()
|
||||
{
|
||||
static t_sig_pending data = {};
|
||||
|
||||
return (&data);
|
||||
}
|
||||
|
||||
t_error append_signal(int signal, int signal_data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void sigint_handle(int sig, siginfo_t *info, void *ucontext)
|
||||
{
|
||||
(void)(sig);
|
||||
|
|
@ -57,13 +79,26 @@ t_error install_signal(void)
|
|||
data = (struct sigaction){};
|
||||
data.sa_sigaction = sigint_handle;
|
||||
data.sa_flags = SA_SIGINFO | SA_NOCLDWAIT;
|
||||
// if (sigaction(SIGINT, &data, NULL))
|
||||
// return (ERROR);
|
||||
if (sigaction(SIGINT, &data, NULL))
|
||||
return (ERROR);
|
||||
|
||||
data.sa_sigaction = sigquit_handle;
|
||||
if (sigaction(SIGQUIT, &data, NULL))
|
||||
return (ERROR);
|
||||
|
||||
data.sa_handler = SIG_DFL;
|
||||
sigemptyset(&data.sa_mask);
|
||||
if (sigaction(SIGTSTP, &data, NULL))
|
||||
return (ERROR);
|
||||
if (sigaction(SIGTTIN, &data, NULL))
|
||||
return (ERROR);
|
||||
if (sigaction(SIGTTOU, &data, NULL))
|
||||
return (ERROR);
|
||||
data.sa_handler = SIG_IGN;
|
||||
if (sigaction(SIGCHLD, &data, NULL))
|
||||
return (ERROR);
|
||||
|
||||
|
||||
// data.sa_sigaction = sigsegv_handle;
|
||||
// if (sigaction(SIGSEGV, &data, NULL))
|
||||
// return (ERROR);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue