From 32eab95d48fd261e05b1e53f736dfd7dd225f421 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Thu, 25 Nov 2021 22:44:35 +0100 Subject: [PATCH] qq recherches sur le signal et heredoc --- srcs/parsing/redirections/here_doc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/srcs/parsing/redirections/here_doc.c b/srcs/parsing/redirections/here_doc.c index b61d87f..1a551a7 100644 --- a/srcs/parsing/redirections/here_doc.c +++ b/srcs/parsing/redirections/here_doc.c @@ -6,7 +6,7 @@ /* 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); } +// 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) { char *line; @@ -68,7 +82,8 @@ static int here_doc_write(char *delimiter, int doc_fd) signal_action.sa_handler = sigint_handler_heredoc; sigaction(SIGINT, &signal_action, NULL); 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; while (1) {