diff options
-rw-r--r-- | src/c_init.c | 8 | ||||
-rw-r--r-- | src/c_input.c | 18 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/c_init.c b/src/c_init.c index 1cc31b0..d80b9ea 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -121,20 +121,20 @@ short c_gnl(int fd, char **line, char psx, t_msh *msh) { t_caps tcaps; - char nread[5]; + char nread[4]; c_init_line(psx, &tcaps); tputs(tgetstr("cr", NULL), 1, ft_putchar); m_prompt_psx(psx, msh); - ft_bzero(nread, 5); + ft_bzero(nread, 4); tcaps.plen = (unsigned int)m_plen(msh->ps[psx - 1]); tcaps.plen += (psx != 1); if (!(c_get_win_size(&tcaps.ws))) return (-1); while (!(ft_strchr(nread, '\n'))) { - ft_bzero(nread, 5); - if (!(read(fd, nread, 4))) + ft_bzero(nread, 4); + if (!(read(fd, nread, 3))) return (0); else *line = c_process_key(nread, &tcaps, msh); diff --git a/src/c_input.c b/src/c_input.c index 7a23b90..8f15449 100644 --- a/src/c_input.c +++ b/src/c_input.c @@ -23,6 +23,21 @@ #include "m_prompt.h" #include "m_loop.h" + +void c_signal_int(int signo) +{ + signal(SIGINT, c_signal_int); + (void)signo; + ioctl(1, TIOCSTI, "\002"); +} + +void signal_ign(int signo) +{ + signal(SIGINT, c_signal_int); + (void)signo; + signal(SIGTSTP, SIG_IGN); +} + short c_init_line(char psx, t_caps *tcaps) { @@ -34,7 +49,8 @@ short if (!tgetent(NULL, term)) return (-1); c_set_term_raw(1); - signal(SIGINT, SIG_IGN); + signal(SIGINT, c_signal_int); + signal(SIGQUIT, signal_ign); tcaps->cpos = 0; tcaps->lpos = 0; tcaps->nlines = 1; |