diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 7206e2e2da7..0d7e3b94e7f 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -19,10 +19,12 @@ #include "commands/trigger.h" #include "executor/spi.h" #include "funcapi.h" +#include "libpq/pqsignal.h" #include "mb/pg_wchar.h" #include "miscadmin.h" #include "nodes/makefuncs.h" #include "parser/parse_type.h" +#include "tcop/tcopprot.h" #include "utils/fmgroids.h" #include "utils/guc.h" #include "utils/lsyscache.h" @@ -552,6 +554,18 @@ plperl_init_interp(void) if (!perl_sys_init_done) { PERL_SYS_INIT3(&nargs, (char ***) &embedding, (char ***) &dummy_perl_env); + + /* + * For unclear reasons, PERL_SYS_INIT3 sets the SIGFPE handler to + * SIG_IGN. Aside from being extremely unfriendly behavior for a + * library, this is dumb on the grounds that the results of a + * SIGFPE in this state are undefined according to POSIX, and in + * fact you get a forced process kill at least on Linux. Hence, + * restore the SIGFPE handler to the backend's standard setting. + * (See Perl bug 114574 for more information.) + */ + pqsignal(SIGFPE, FloatExceptionHandler); + perl_sys_init_done = 1; } #endif