[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] poke: use pthread functions only if available
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] poke: use pthread functions only if available |
Date: |
Wed, 21 Feb 2024 11:47:48 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi Hannes.
Thanks for the patch.
How does poke handle ctrl-C in the Windows terminal with this patch
applied? Does it get back to the (poke) prompt or kills the process?
> 2024-02-15 Hannes Domani <ssbssa@yahoo.de>
>
> * poke/pk-repl.c (poke_sigint_handler, pk_repl): Use pthread
> functions only if available.
> ---
> poke/pk-repl.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/poke/pk-repl.c b/poke/pk-repl.c
> index 19f2a0d9..6de33455 100644
> --- a/poke/pk-repl.c
> +++ b/poke/pk-repl.c
> @@ -39,6 +39,7 @@
> #include "pk-utils.h"
> #include "pk-map.h"
>
> +#ifdef HAVE_PTHREAD_H
> /* The thread that contains the non-local entry point for reentering
> the REPL. */
> static pthread_t volatile ctrlc_thread;
> @@ -46,6 +47,7 @@ static pthread_t volatile ctrlc_thread;
> static sigjmp_buf /*volatile*/ ctrlc_buf;
> /* When nonzero, ctrlc_thread and ctrlc_buf contain valid values. */
> static int volatile ctrlc_buf_valid;
> +#endif
>
> /* This function is called repeatedly by the readline library, when
> generating potential command line completions.
> @@ -230,6 +232,7 @@ banner (void)
>
> }
>
> +#ifdef HAVE_PTHREAD_H
> static _GL_ASYNC_SAFE void
> poke_sigint_handler (int sig)
> {
> @@ -275,6 +278,7 @@ poke_sigint_handler (int sig)
> raise (SIGINT);
> }
> }
> +#endif
>
> /* Return a copy of TEXT, with every instance of the space character
> prepended with the backslash character. The caller is responsible
> @@ -355,6 +359,7 @@ pk_repl (void)
> /* Let the inputrc parser know who we are. */
> rl_readline_name = "gnupoke";
>
> +#ifdef HAVE_PTHREAD_H
> /* Arrange for the current line to be cancelled on SIGINT.
> Since some library code is also interested in SIGINT
> (GNU libtextstyle, via gnulib module fatal-signal), it is better
> @@ -366,6 +371,7 @@ pk_repl (void)
> sa.sa_flags = 0;
> sigemptyset (&sa.sa_mask);
> sigaction (SIGINT, &sa, NULL);
> +#endif
>
> #if defined HAVE_READLINE_HISTORY_H
> char *poke_history = NULL;
> @@ -389,9 +395,11 @@ pk_repl (void)
> rl_filename_quote_characters = " ";
> rl_filename_quoting_function = escape_metacharacters;
>
> +#ifdef HAVE_PTHREAD_H
> ctrlc_thread = pthread_self ();
> sigsetjmp (ctrlc_buf, 1);
> ctrlc_buf_valid = 1;
> +#endif
>
> while (!poke_exit_p)
> {
> @@ -448,7 +456,9 @@ pk_repl (void)
> }
> #endif
>
> +#ifdef HAVE_PTHREAD_H
> ctrlc_buf_valid = 0;
> +#endif
> }
>
> static int saved_point;
- [PATCH] poke: use pthread functions only if available, Hannes Domani, 2024/02/15
- Re: [PATCH] poke: use pthread functions only if available,
Jose E. Marchesi <=
- Re: [PATCH] poke: use pthread functions only if available, Hannes Domani, 2024/02/21
- Re: [PATCH] poke: use pthread functions only if available, Jose E. Marchesi, 2024/02/21
- Re: [PATCH] poke: use pthread functions only if available, Hannes Domani, 2024/02/21
- Re: [PATCH] poke: use pthread functions only if available, Hannes Domani, 2024/02/21
- Re: [PATCH] poke: use pthread functions only if available, Jose E. Marchesi, 2024/02/22
- Re: [PATCH] poke: use pthread functions only if available, Hannes Domani, 2024/02/22
- Re: [PATCH] poke: use pthread functions only if available, Jose E. Marchesi, 2024/02/22