Skip to content

Commit

Permalink
main: Unregister signal handler before destroying my_perl
Browse files Browse the repository at this point in the history
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
jswright authored and rgs committed Jun 7, 2009
1 parent d8ada40 commit 01be072
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion miniperlmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ main(int argc, char **argv, char **env)
#endif
{
dVAR;
int exitstatus;
int exitstatus, i;
#ifdef PERL_GLOBAL_STRUCT
struct perl_vars *plvarsp = init_global_struct();
# ifdef PERL_GLOBAL_STRUCT_PRIVATE
Expand Down Expand Up @@ -116,6 +116,13 @@ main(int argc, char **argv, char **env)
if (!exitstatus)
perl_run(my_perl);

/* Unregister our signal handler before destroying my_perl */
for (i = 0; PL_sig_name[i]; i++) {
if (rsignal_state(PL_sig_num[i]) == (Sighandler_t) PL_csighandlerp) {
rsignal(PL_sig_num[i], (Sighandler_t) SIG_DFL);
}
}

exitstatus = perl_destruct(my_perl);

perl_free(my_perl);
Expand Down

0 comments on commit 01be072

Please sign in to comment.