diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-11-07 23:37:26 +0100 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-11-07 23:37:26 +0100 |
commit | 1494b105cce7eac172bd07cf324ec48a37de46bf (patch) | |
tree | 4c94a2e7f3e48b40338823c18fefd293e42add5a | |
parent | c_ctrls (diff) | |
download | 42-minishell-1494b105cce7eac172bd07cf324ec48a37de46bf.tar.gz 42-minishell-1494b105cce7eac172bd07cf324ec48a37de46bf.tar.bz2 42-minishell-1494b105cce7eac172bd07cf324ec48a37de46bf.tar.xz 42-minishell-1494b105cce7eac172bd07cf324ec48a37de46bf.tar.zst 42-minishell-1494b105cce7eac172bd07cf324ec48a37de46bf.zip |
ctrlc \
-rw-r--r-- | src/c_ctrls.c | 14 | ||||
-rw-r--r-- | src/c_ctrls.h | 1 | ||||
-rw-r--r-- | src/c_input.c | 3 | ||||
-rw-r--r-- | src/m_loop.c | 5 | ||||
-rw-r--r-- | src/ret | bin | 0 -> 67 bytes |
5 files changed, 19 insertions, 4 deletions
diff --git a/src/c_ctrls.c b/src/c_ctrls.c index 2f066d6..dce9db6 100644 --- a/src/c_ctrls.c +++ b/src/c_ctrls.c @@ -19,6 +19,17 @@ #include "c_utils.h" #include "m_prompt.h" +t_msh *c_get_msh(int mode, t_msh *src) +{ + static t_msh *msh; + + if (mode == 1) + { + msh = src; + } + return (msh); +} + short c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh) { tputs(tgetstr("cl", NULL), 1, ft_putchar); @@ -43,8 +54,9 @@ void c_signal_int(int signo) msh = NULL; signal(SIGINT, c_signal_int); (void)signo; - msh->ret = 130; + msh = c_get_msh(0, msh); ioctl(1, TIOCSTI, "\002"); + msh->ret = 130; } void c_signal_ign(int signo) diff --git a/src/c_ctrls.h b/src/c_ctrls.h index abce955..14adbda 100644 --- a/src/c_ctrls.h +++ b/src/c_ctrls.h @@ -16,6 +16,7 @@ # include "c_init.h" # include "s_struct.h" +t_msh *c_get_msh(int mode, t_msh *src); short c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh); char *c_ctrl_c(char **line, char *buf, t_msh *msh); void c_signal_int(int signo); diff --git a/src/c_input.c b/src/c_input.c index ce571ca..9023f37 100644 --- a/src/c_input.c +++ b/src/c_input.c @@ -13,7 +13,6 @@ #include <unistd.h> #include <stdlib.h> #include <libft.h> -#include <signal.h> #include <term.h> #include "c_ctrls.h" @@ -35,8 +34,6 @@ short if (!tgetent(NULL, term)) return (-1); c_set_term_raw(1); - signal(SIGINT, c_signal_int); - signal(SIGQUIT, c_signal_ign); tcaps->cpos = 0; tcaps->lpos = 0; tcaps->nlines = 1; diff --git a/src/m_loop.c b/src/m_loop.c index 03ce8e2..6444c1b 100644 --- a/src/m_loop.c +++ b/src/m_loop.c @@ -14,6 +14,7 @@ #include <stdlib.h> #include <fcntl.h> #include <unistd.h> +#include <signal.h> #ifdef __linux__ # include <linux/limits.h> #else @@ -21,6 +22,7 @@ #endif #include "c_init.h" +#include "c_ctrls.h" #include "d_define.h" #include "e_line.h" #include "m_loop_multis.h" @@ -136,6 +138,9 @@ unsigned char m_loop(int fd, t_msh *msh) gnl = 1; msh->curr_hist_ptr = hist; + c_get_msh(1, msh); + signal(SIGINT, c_signal_int); + signal(SIGQUIT, c_signal_ign); while (gnl > 0) { gnl = (fd == STDIN_FILENO) ? c_gnl(fd, &line, 1, msh) : Binary files differ |