diff options
-rw-r--r-- | src/c_ctrls.c | 60 | ||||
-rw-r--r-- | src/c_ctrls.h | 4 | ||||
-rw-r--r-- | src/c_init.c | 1 | ||||
-rw-r--r-- | src/e_externs.c | 2 | ||||
-rw-r--r-- | src/s_struct.h | 1 |
5 files changed, 40 insertions, 28 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); } diff --git a/src/c_ctrls.h b/src/c_ctrls.h index 14adbda..63710a0 100644 --- a/src/c_ctrls.h +++ b/src/c_ctrls.h @@ -16,10 +16,10 @@ # include "c_init.h" # include "s_struct.h" +void c_signal_int(int signo); +void c_signal_ign(int signo); 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); -void c_signal_ign(int signo); #endif diff --git a/src/c_init.c b/src/c_init.c index 0939b29..0133f7b 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -123,6 +123,7 @@ short tputs(tgetstr("cr", NULL), 1, ft_putchar); m_prompt_psx(psx, msh); ft_bzero(nread, 4); + msh->sig = 0; tcaps.plen = (unsigned int)m_plen(msh->ps[psx - 1]); if (!(c_get_win_size(&tcaps.ws))) return (-1); diff --git a/src/e_externs.c b/src/e_externs.c index 6e1e75a..b184728 100644 --- a/src/e_externs.c +++ b/src/e_externs.c @@ -113,7 +113,7 @@ static void e_exec_path(const char fullpath[], { while (wait(&status) != pid) ; - msh->ret = WEXITSTATUS(status); + msh->ret = (msh->sig != 0) ? msh->sig : WEXITSTATUS(status); } } diff --git a/src/s_struct.h b/src/s_struct.h index ee70a31..3461408 100644 --- a/src/s_struct.h +++ b/src/s_struct.h @@ -96,6 +96,7 @@ typedef struct s_msh struct s_lvars *vars; struct s_lalias *alias; int argc; + int sig; char **argv; char **envp; char *prev_hist; |