From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Fri, 25 Oct 2013 01:51:00 +0000 (-0400)
Subject: Ignore SIGSYS during initdb.
X-Git-Tag: REL9_4_BETA1~1014
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e1e47c7c00d01d1b2fd3a4354f48be427a30f67;p=postgresql

Ignore SIGSYS during initdb.

This prevents the recently-added probe for shm_open() from crashing
on platforms that are impolite enough to deliver a signal rather than
returning ENOSYS for an unimplemented kernel call.  At least on the
one known example (HPUX 10.20), ignoring SIGSYS does result in the
desired behavior of getting an ENOSYS error return instead.

Per discussion, we might later wish to do this in the backend as well,
but for now it seems sufficient to do it in initdb.
---

diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 3983b23731..30e3701f92 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -3197,6 +3197,11 @@ setup_signals(void)
 #ifdef SIGPIPE
 	pqsignal(SIGPIPE, SIG_IGN);
 #endif
+
+	/* Prevent SIGSYS so we can probe for kernel calls that might not work */
+#ifdef SIGSYS
+	pqsignal(SIGSYS, SIG_IGN);
+#endif
 }