1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
Description: Only use SA_SIGINFO if available (e.g. not on GNU/Hurd)
Author: Peter Pentchev <roam@ringlet.net>
Forwarded: no
Last-Update: 2016-04-05
--- a/lib/connectchild.c
+++ b/lib/connectchild.c
@@ -129,6 +129,7 @@
return NULL;
}
+#ifdef SA_SIGINFO
if (currentsig.sa_flags & SA_SIGINFO) { /* sa_sigaction. */
isourhandler = (currentsig.sa_sigaction == sigio);
@@ -146,6 +147,7 @@
}
}
else { /* sa_handler. */
+#endif
isourhandler = 0; /* we install with SA_SIGINFO. */
if (currentsig.sa_handler != SIG_IGN
@@ -155,12 +157,16 @@
else
slog(LOG_DEBUG,
"%s: no SIGIO handler previously installed", function);
+#ifdef SA_SIGINFO
}
+#endif
if (!isourhandler) {
newsig = currentsig; /* keep same as much as possible. */
newsig.sa_sigaction = sigio;
+#ifdef SA_SIGINFO
newsig.sa_flags |= SA_SIGINFO;
+#endif
slog(LOG_DEBUG, "%s: our signal handler is not installed, installing ...",
function);
@@ -1288,6 +1294,7 @@
return;
}
+#ifdef SA_SIGINFO
if (originalsig.sa_flags & SA_SIGINFO
&& originalsig.sa_sigaction != NULL) {
const char *msgv[] =
@@ -1302,6 +1309,7 @@
originalsig.sa_sigaction(sig, sip, scp);
}
else {
+#endif
if (originalsig.sa_handler != SIG_IGN
&& originalsig.sa_handler != SIG_DFL) {
const char *msgv[] =
@@ -1315,7 +1323,9 @@
originalsig.sa_handler(sig);
}
+#ifdef SA_SIGINFO
}
+#endif
if (sockscf.connectchild == 0) {
sockscf.state.insignal = 0;
--- a/lib/upnp.c
+++ b/lib/upnp.c
@@ -801,7 +801,9 @@
oursig = oldsig;
oursig.sa_handler = sighandler;
+#ifdef SA_SIGINFO
oursig.sa_flags |= SA_SIGINFO;
+#endif
if (sigaction(signalv[i], &oursig, NULL) != 0) {
swarn("%s: sigaction(%d)", function, signalv[i]);
--- a/sockd/monitor.c
+++ b/sockd/monitor.c
@@ -408,7 +408,11 @@
fd_set *rset;
bzero(&sigact, sizeof(sigact));
+#ifdef SA_SIGINFO
sigact.sa_flags = SA_RESTART | SA_SIGINFO;
+#else
+ sigact.sa_flags = SA_RESTART;
+#endif
sigact.sa_sigaction = siginfo;
#if HAVE_SIGNAL_SIGINFO
--- a/sockd/mother_util.c
+++ b/sockd/mother_util.c
@@ -259,7 +259,11 @@
*/
bzero(&sigact, sizeof(sigact));
+#ifdef SA_SIGINFO
sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP | SA_SIGINFO;
+#else
+ sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+#endif
sigact.sa_sigaction = siginfo;
#if HAVE_SIGNAL_SIGINFO
@@ -292,7 +296,9 @@
if (sigaction(ignoresignalv[i], &sigact, NULL) != 0)
serr("sigaction(%d)", ignoresignalv[i]);
+#ifdef SA_SIGINFO
sigact.sa_flags = SA_SIGINFO; /* want to be interrupted. */
+#endif
sigact.sa_sigaction = sigalrm;
if (sigaction(SIGALRM, &sigact, NULL) != 0)
serr("sigaction(SIGALRM)");
--- a/sockd/sockd.c
+++ b/sockd/sockd.c
@@ -236,7 +236,11 @@
newprocinit();
bzero(&sigact, sizeof(sigact));
+#ifdef SA_SIGINFO
sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP | SA_SIGINFO;
+#else
+ sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+#endif
sigact.sa_sigaction = sighup_child;
if (sigaction(SIGHUP, &sigact, NULL) != 0) {
--- a/sockd/sockd_child.c
+++ b/sockd/sockd_child.c
@@ -1828,7 +1828,11 @@
* Next install a SIGHUP handler. Same for all children and
* different from the one mother uses.
*/
+#ifdef SA_SIGINFO
sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP | SA_SIGINFO;
+#else
+ sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+#endif
sigact.sa_sigaction = sighup_child;
if (sigaction(SIGHUP, &sigact, NULL) != 0)
--- a/sockd/sockd_io.c
+++ b/sockd/sockd_io.c
@@ -329,7 +329,11 @@
#endif /* DIAGNOSTIC */
bzero(&sigact, sizeof(sigact));
+#ifdef SA_SIGINFO
sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP | SA_SIGINFO;
+#else
+ sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+#endif
sigact.sa_sigaction = siginfo;
#if HAVE_SIGNAL_SIGINFO
--- a/sockd/sockd_negotiate.c
+++ b/sockd/sockd_negotiate.c
@@ -227,7 +227,11 @@
int sendfailed;
bzero(&sigact, sizeof(sigact));
+#ifdef SA_SIGINFO
sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP | SA_SIGINFO;
+#else
+ sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+#endif
sigact.sa_sigaction = siginfo;
#if HAVE_SIGNAL_SIGINFO
--- a/sockd/sockd_request.c
+++ b/sockd/sockd_request.c
@@ -247,7 +247,11 @@
fd_set *rset;
bzero(&sigact, sizeof(sigact));
+#ifdef SA_SIGINFO
sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP | SA_SIGINFO;
+#else
+ sigact.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+#endif
sigact.sa_sigaction = siginfo;
#if HAVE_SIGNAL_SIGINFO
|