diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-11-09 17:57:48 +0100 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-11-09 17:57:48 +0100 |
commit | b74d66ca6e9fe5ab557260e1d27299a8bd562640 (patch) | |
tree | f499009d361a959386340d719e0fd3da7a2891ce /src/c_ctrls.c | |
parent | ctrlc \ (diff) | |
download | 42-minishell-b74d66ca6e9fe5ab557260e1d27299a8bd562640.tar.gz 42-minishell-b74d66ca6e9fe5ab557260e1d27299a8bd562640.tar.bz2 42-minishell-b74d66ca6e9fe5ab557260e1d27299a8bd562640.tar.xz 42-minishell-b74d66ca6e9fe5ab557260e1d27299a8bd562640.tar.zst 42-minishell-b74d66ca6e9fe5ab557260e1d27299a8bd562640.zip |
hellyeah brother, norm not checked because fuck lazare, new file and msh->sig
Diffstat (limited to 'src/c_ctrls.c')
-rw-r--r-- | src/c_ctrls.c | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/src/c_ctrls.c b/src/c_ctrls.c index dce9db6..dae91a2 100644 --- a/src/c_ctrls.c +++ b/src/c_ctrls.c @@ -21,47 +21,57 @@ t_msh *c_get_msh(int mode, t_msh *src) { - static t_msh *msh; + static t_msh *msh; - if (mode == 1) - { - msh = src; - } - return (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); - m_prompt_psx(1, msh); - c_redraw_line(line, tcaps, msh); - return (1); + tputs(tgetstr("cl", NULL), 1, ft_putchar); + m_prompt_psx(1, msh); + c_redraw_line(line, tcaps, msh); + return (1); } char *c_ctrl_c(char **line, char *buf, t_msh *msh) { - msh->ret = 130; - buf[0] = '\n'; - write(1, "\n", 1); - ft_memdel((void**)line); - return (ft_strdup("\0")); + msh->ret = 130; + buf[0] = '\n'; + write(1, "\n", 1); + ft_memdel((void**)line); + return (ft_strdup("\0")); } void c_signal_int(int signo) { - t_msh *msh; + static t_msh *msh; - msh = NULL; - signal(SIGINT, c_signal_int); - (void)signo; - msh = c_get_msh(0, msh); - ioctl(1, TIOCSTI, "\002"); - msh->ret = 130; + msh = NULL; + signal(SIGINT, c_signal_int); + (void)signo; + write(1, "\n", 1); + msh = c_get_msh(0, msh); + msh->sig = 130; + ioctl(1, TIOCSTI, "\002"); } void c_signal_ign(int signo) { - signal(SIGINT, c_signal_int); - (void)signo; - signal(SIGTSTP, SIG_IGN); + t_msh *msh; + + msh = NULL; + if (signo == 3) + { + write(1, "\n", 1); + msh = c_get_msh(0, msh); + msh->sig = 131; + } + signal(SIGINT, c_signal_int); + (void)signo; + signal(SIGTSTP, SIG_IGN); } |