summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-07-16 02:26:12 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-07-16 02:26:12 +0000
commita10b1e109d1f901ff6cb267ca6a30834468b37b7 (patch)
treeebcbc86381491825f373576d48c240f48f41da45 /util.c
parent1095be3767b805178c80d95f5b7a502999848f8b (diff)
downloadperl-a10b1e109d1f901ff6cb267ca6a30834468b37b7.tar.gz
Integrate change #16844 from maint:
extension of change#16332: isolate signal diddling to the main interpreter (fixes signal-related races, e.g. when multiple threads run system()) p4raw-link: @16844 on //depot/maint-5.6/perl: 9bc2ac260e3c5ad531ff50393278b22d570db209 p4raw-link: @16332 on //depot/maint-5.6/perl: 9bf7742e23b67e3d7c671615795c570c51951513 p4raw-id: //depot/perl@17569 p4raw-integrated: from //depot/maint-5.6/perl@17567 'merge in' util.c (@16508..)
Diffstat (limited to 'util.c')
-rw-r--r--util.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/util.c b/util.c
index e42efe3f11..7355b96907 100644
--- a/util.c
+++ b/util.c
@@ -2349,6 +2349,12 @@ Perl_rsignal(pTHX_ int signo, Sighandler_t handler)
{
struct sigaction act, oact;
+#ifdef USE_ITHREADS
+ /* only "parent" interpreter can diddle signals */
+ if (PL_curinterp != aTHX)
+ return SIG_ERR;
+#endif
+
act.sa_handler = handler;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
@@ -2383,6 +2389,12 @@ Perl_rsignal_save(pTHX_ int signo, Sighandler_t handler, Sigsave_t *save)
{
struct sigaction act;
+#ifdef USE_ITHREADS
+ /* only "parent" interpreter can diddle signals */
+ if (PL_curinterp != aTHX)
+ return -1;
+#endif
+
act.sa_handler = handler;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
@@ -2401,6 +2413,12 @@ Perl_rsignal_save(pTHX_ int signo, Sighandler_t handler, Sigsave_t *save)
int
Perl_rsignal_restore(pTHX_ int signo, Sigsave_t *save)
{
+#ifdef USE_ITHREADS
+ /* only "parent" interpreter can diddle signals */
+ if (PL_curinterp != aTHX)
+ return -1;
+#endif
+
return sigaction(signo, save, (struct sigaction *)NULL);
}
@@ -2409,6 +2427,12 @@ Perl_rsignal_restore(pTHX_ int signo, Sigsave_t *save)
Sighandler_t
Perl_rsignal(pTHX_ int signo, Sighandler_t handler)
{
+#ifdef USE_ITHREADS
+ /* only "parent" interpreter can diddle signals */
+ if (PL_curinterp != aTHX)
+ return SIG_ERR;
+#endif
+
return PerlProc_signal(signo, handler);
}
@@ -2427,6 +2451,12 @@ Perl_rsignal_state(pTHX_ int signo)
{
Sighandler_t oldsig;
+#ifdef USE_ITHREADS
+ /* only "parent" interpreter can diddle signals */
+ if (PL_curinterp != aTHX)
+ return SIG_ERR;
+#endif
+
sig_trapped = 0;
oldsig = PerlProc_signal(signo, sig_trap);
PerlProc_signal(signo, oldsig);
@@ -2438,6 +2468,11 @@ Perl_rsignal_state(pTHX_ int signo)
int
Perl_rsignal_save(pTHX_ int signo, Sighandler_t handler, Sigsave_t *save)
{
+#ifdef USE_ITHREADS
+ /* only "parent" interpreter can diddle signals */
+ if (PL_curinterp != aTHX)
+ return -1;
+#endif
*save = PerlProc_signal(signo, handler);
return (*save == SIG_ERR) ? -1 : 0;
}
@@ -2445,6 +2480,11 @@ Perl_rsignal_save(pTHX_ int signo, Sighandler_t handler, Sigsave_t *save)
int
Perl_rsignal_restore(pTHX_ int signo, Sigsave_t *save)
{
+#ifdef USE_ITHREADS
+ /* only "parent" interpreter can diddle signals */
+ if (PL_curinterp != aTHX)
+ return -1;
+#endif
return (PerlProc_signal(signo, *save) == SIG_ERR) ? -1 : 0;
}