diff --git a/miniperlmain.c b/miniperlmain.c index f60a3e018091..f2302c2951c2 100644 --- a/miniperlmain.c +++ b/miniperlmain.c @@ -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 @@ -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);