summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2016-01-12 14:47:07 +0000
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2016-01-26 10:51:42 +0000
commitcdfe2e65ec1960d301d083bee421388e064cd234 (patch)
tree37b5c45025c58e9b119007c55b1c261603ef92e6 /mg.c
parent34e79b757ab6100d44bdbfa6f9603793a4215bbf (diff)
downloadperl-cdfe2e65ec1960d301d083bee421388e064cd234.tar.gz
Probe for and expose more fields for SA_SIGINFO
These are all specified by POSIX/SUSv3, but not all platforms have them, as mentioned in POSIX.pm. We can only test the pid, uid and code fields, since they are the only ones that are defined for a user-sent signal.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/mg.c b/mg.c
index f8d8f33a3a..bb5cba104c 100644
--- a/mg.c
+++ b/mg.c
@@ -3340,13 +3340,27 @@ Perl_sighandler(int sig)
* addr, status, and band are defined by POSIX/SUSv3. */
(void)hv_stores(sih, "signo", newSViv(sip->si_signo));
(void)hv_stores(sih, "code", newSViv(sip->si_code));
-#if 0 /* XXX TODO: Configure scan for the existence of these, but even that does not help if the SA_SIGINFO is not implemented according to the spec. */
- hv_stores(sih, "errno", newSViv(sip->si_errno));
- hv_stores(sih, "status", newSViv(sip->si_status));
- hv_stores(sih, "uid", newSViv(sip->si_uid));
- hv_stores(sih, "pid", newSViv(sip->si_pid));
- hv_stores(sih, "addr", newSVuv(PTR2UV(sip->si_addr)));
- hv_stores(sih, "band", newSViv(sip->si_band));
+#ifdef HAS_SIGINFO_SI_ERRNO
+ (void)hv_stores(sih, "errno", newSViv(sip->si_errno));
+#endif
+#ifdef HAS_SIGINFO_SI_STATUS
+ (void)hv_stores(sih, "status", newSViv(sip->si_status));
+#endif
+#ifdef HAS_SIGINFO_SI_UID
+ {
+ SV *uid = newSV(0);
+ sv_setuid(uid, sip->si_uid);
+ (void)hv_stores(sih, "uid", uid);
+ }
+#endif
+#ifdef HAS_SIGINFO_SI_PID
+ (void)hv_stores(sih, "pid", newSViv(sip->si_pid));
+#endif
+#ifdef HAS_SIGINFO_SI_ADDR
+ (void)hv_stores(sih, "addr", newSVuv(PTR2UV(sip->si_addr)));
+#endif
+#ifdef HAS_SIGINFO_SI_BAND
+ (void)hv_stores(sih, "band", newSViv(sip->si_band));
#endif
EXTEND(SP, 2);
PUSHs(rv);