qq recherches sur le signal et heredoc

This commit is contained in:
hugogogo
2021-11-25 22:44:35 +01:00
parent ac11eee947
commit 32eab95d48

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */ /* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */ /* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */
/* Updated: 2021/11/25 10:05:44 by hulamy ### ########.fr */ /* Updated: 2021/11/25 22:21:16 by hulamy ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -59,6 +59,20 @@ int void_func_return_readline(void)
return (0); return (0);
} }
// rl_done
// Setting this to a non-zero value causes Readline to return the current line
// immediately
// rl_event_hook
// If non-zero, this is the address of a function to call periodically when Readline
// is waiting for terminal input. By default, this will be called at most ten times
// a second if there is no keyboard input
// from stackoverflow (https://stackoverflow.com/questions/53165704/readline-c-force-return-of-certain-text-in-readline)
// "rl_done is only checked in the event loop. When you give it a null event hook
// function, it checks the rl_done and exits"
//
// rl_signal_event_hook
// If non-zero, this is the address of a function to call if a read system call is
// interrupted when Readline is reading terminal input.
static int here_doc_write(char *delimiter, int doc_fd) static int here_doc_write(char *delimiter, int doc_fd)
{ {
char *line; char *line;
@@ -68,7 +82,8 @@ static int here_doc_write(char *delimiter, int doc_fd)
signal_action.sa_handler = sigint_handler_heredoc; signal_action.sa_handler = sigint_handler_heredoc;
sigaction(SIGINT, &signal_action, NULL); sigaction(SIGINT, &signal_action, NULL);
switch_heredoc_sigint = 0; switch_heredoc_sigint = 0;
rl_event_hook = void_func_return_readline; //rl_event_hook = void_func_return_readline;
rl_signal_event_hook = void_func_return_readline;
line_count = 0; line_count = 0;
while (1) while (1)
{ {