Skip to content

Commit

Permalink
csighandler3: forward signals to the main thread if not a perl thread
Browse files Browse the repository at this point in the history
This is only done for pthreads, Win32 already uses something like
my suggestion from Perl#22530 and unlike POSIX doesn't have a way to
asynchronously interrupt a thread that I'm aware of.  It's also
complicated by pseudo-processes.

Fixes Perl#22487
  • Loading branch information
tonycoz committed Nov 12, 2024
1 parent 17dd11e commit a071427
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,17 @@ Perl_csighandler3(int sig, Siginfo_t *sip PERL_UNUSED_DECL, void *uap PERL_UNUSE
dTHX;
#endif

#if defined(USE_ITHREADS) && !defined(WIN32)
if (!aTHX) {
/* presumably ths signal is being delivered to a non-perl
* thread, presumably created by a library, redirect it to the
* main thread.
*/
pthread_kill(PL_main_thread, sig);
return;
}
#endif

#ifdef PERL_USE_3ARG_SIGHANDLER
#if defined(__cplusplus) && defined(__GNUC__)
/* g++ doesn't support PERL_UNUSED_DECL, so the sip and uap
Expand Down

0 comments on commit a071427

Please sign in to comment.