develooper Front page | perl.perl5.porters | Postings from December 2006

[PATCH 5.8.8] OS/2: survive SIGCHLD

Thread Next
From:
Ilya Zakharevich
Date:
December 18, 2006 00:55
Subject:
[PATCH 5.8.8] OS/2: survive SIGCHLD
Message ID:
20061218085519.GA14893@powdermilk.math.berkeley.edu
With the current, default, unreliable signal-delivery, on OS/2 when
SIGCHLD is delivered to a Perl process, the whole system becomes
unusable.  I discussed the fact that the current signal architecture
is unacceptable-as-shipped many times; but this facet is slightly new:

  it was obvious that this model of signal delivery will result in a
  deadlock, since SIGCHLD must be acknowledged by the handler (by
  calling wait()).  However, it was not obvious that this would bring
  the system to its knees.

  The (conjectural) reason is that the process gets a priority boost
  during delivery of a Exception; thus the process not only loops
  indefinitely in the signal handler, but also does it on very high
  priority.  As a result, the UI of the computer (which runs on
  "moderate" priority) is starved of CPU, and one cannot start a
  process killer.  (Moreover, I'm not sure that process killer will
  deliver an Exception to a process which is ALREADY inside an
  Exception Handler.)

The attached patch is not a solution, but just a watchdog which would
make Perl process die() when such a condition is detected.  I'm not
sure it is good for general use, but I do not know how exactly to make
it better.

Enjoy,
Ilya

diff -pru perl-5.8.7-min-patched/mg.c perl-5.8.7-patched/mg.c
--- perl-5.8.7-min-patched/mg.c	Fri Apr 22 07:12:48 2005
+++ perl-5.8.7-patched/mg.c	Mon Nov 27 20:59:08 2006
@@ -1226,13 +1226,19 @@ Perl_magic_clearsig(pTHX_ SV *sv, MAGIC 
     return 0;
 }
 
+#ifndef SIG_PENDING_DIE_COUNT
+#  define SIG_PENDING_DIE_COUNT 120
+#endif
+
 void
 Perl_raise_signal(pTHX_ int sig)
 {
     /* Set a flag to say this signal is pending */
     PL_psig_pend[sig]++;
     /* And one to say _a_ signal is pending */
-    PL_sig_pending = 1;
+    if (++PL_sig_pending >= SIG_PENDING_DIE_COUNT)
+	Perl_croak(aTHX_ "Maximal count of pending signals (%lu) exceeded",
+		   (unsigned long)SIG_PENDING_DIE_COUNT);
 }
 
 Signal_t

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About