diff options
author | John Wright <john@johnwright.org> | 2009-05-06 00:47:15 -0600 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-06-07 14:59:56 +0200 |
commit | 01be0729981136a058cce07a897ccdb94609e1c0 (patch) | |
tree | e4f1339d6e4abd0cf92adda183890a8d2cf465df /miniperlmain.c | |
parent | d8ada404a5a63daf28046c6ff04ca8a872c4d63a (diff) | |
download | perl-01be0729981136a058cce07a897ccdb94609e1c0.tar.gz |
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().
Diffstat (limited to 'miniperlmain.c')
-rw-r--r-- | miniperlmain.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/miniperlmain.c b/miniperlmain.c index f60a3e0180..f2302c2951 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); |