Skip to content

Commit 1a0568c

Browse files
committed
csighandler3: forward signals to the main thread if not a perl thread
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
1 parent 9f46dd5 commit 1a0568c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mg.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,17 @@ Perl_csighandler3(int sig, Siginfo_t *sip PERL_UNUSED_DECL, void *uap PERL_UNUSE
15641564
dTHX;
15651565
#endif
15661566

1567+
#if defined(USE_ITHREADS) && !defined(WIN32)
1568+
if (!aTHX) {
1569+
/* presumably ths signal is being delivered to a non-perl
1570+
* thread, presumably created by a library, redirect it to the
1571+
* main thread.
1572+
*/
1573+
pthread_kill(PL_main_thread, sig);
1574+
return;
1575+
}
1576+
#endif
1577+
15671578
#ifdef PERL_USE_3ARG_SIGHANDLER
15681579
#if defined(__cplusplus) && defined(__GNUC__)
15691580
/* g++ doesn't support PERL_UNUSED_DECL, so the sip and uap

0 commit comments

Comments
 (0)