Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

main: Unregister signal handler before destroying my_perl

If the signal handler runs after perl_destruct() has been called, it
will get an invalid (or NULL) my_perl when it asks for the
thread-specific interpreter struct.  This patch resets the signal
handler for any signal previously handled by PL_csighandlerp to SIG_DFL
before calling perl_destruct().
  • Loading branch information...
commit 01be0729981136a058cce07a897ccdb94609e1c0 1 parent d8ada40
John Wright authored May 06, 2009 rgs committed June 07, 2009

Showing 1 changed file with 8 additions and 1 deletion. Show diff stats Hide diff stats

  1. 9  miniperlmain.c
9  miniperlmain.c
@@ -67,7 +67,7 @@ main(int argc, char **argv, char **env)
67 67
 #endif
68 68
 {
69 69
     dVAR;
70  
-    int exitstatus;
  70
+    int exitstatus, i;
71 71
 #ifdef PERL_GLOBAL_STRUCT
72 72
     struct perl_vars *plvarsp = init_global_struct();
73 73
 #  ifdef PERL_GLOBAL_STRUCT_PRIVATE
@@ -116,6 +116,13 @@ main(int argc, char **argv, char **env)
116 116
     if (!exitstatus)
117 117
         perl_run(my_perl);
118 118
 
  119
+    /* Unregister our signal handler before destroying my_perl */
  120
+    for (i = 0; PL_sig_name[i]; i++) {
  121
+	if (rsignal_state(PL_sig_num[i]) == (Sighandler_t) PL_csighandlerp) {
  122
+	    rsignal(PL_sig_num[i], (Sighandler_t) SIG_DFL);
  123
+	}
  124
+    }
  125
+
119 126
     exitstatus = perl_destruct(my_perl);
120 127
 
121 128
     perl_free(my_perl);

0 notes on commit 01be072

Please sign in to comment.
Something went wrong with that request. Please try again.