17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57257d1b4Sraf * Common Development and Distribution License (the "License").
67257d1b4Sraf * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
21*3e5de5d0SEric Sproul /*
22*3e5de5d0SEric Sproul * Copyright 2015 Circonus, Inc. All rights reserved.
23*3e5de5d0SEric Sproul */
247257d1b4Sraf
257c478bd9Sstevel@tonic-gate /*
267257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
277c478bd9Sstevel@tonic-gate * Use is subject to license terms.
287c478bd9Sstevel@tonic-gate */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
317c478bd9Sstevel@tonic-gate /* All Rights Reserved */
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate * Print the name of the siginfo indicated by "sig", along with the
357c478bd9Sstevel@tonic-gate * supplied message
367c478bd9Sstevel@tonic-gate */
377c478bd9Sstevel@tonic-gate
387257d1b4Sraf #include "lint.h"
397c478bd9Sstevel@tonic-gate #include "_libc_gettext.h"
407c478bd9Sstevel@tonic-gate #include <sys/types.h>
417c478bd9Sstevel@tonic-gate #include <stdio.h>
427c478bd9Sstevel@tonic-gate #include <unistd.h>
437c478bd9Sstevel@tonic-gate #include <string.h>
447c478bd9Sstevel@tonic-gate #include <signal.h>
457c478bd9Sstevel@tonic-gate #include <siginfo.h>
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate #define strsignal(i) (_libc_gettext(_sys_siglistp[i]))
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gate void
psiginfo(const siginfo_t * sip,const char * s)50*3e5de5d0SEric Sproul psiginfo(const siginfo_t *sip, const char *s)
517c478bd9Sstevel@tonic-gate {
527c478bd9Sstevel@tonic-gate char buf[256];
537c478bd9Sstevel@tonic-gate char *c;
547c478bd9Sstevel@tonic-gate const struct siginfolist *listp;
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate if (sip == 0)
577c478bd9Sstevel@tonic-gate return;
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gate if (sip->si_code <= 0) {
617c478bd9Sstevel@tonic-gate (void) snprintf(buf, sizeof (buf),
627c478bd9Sstevel@tonic-gate _libc_gettext("%s : %s ( from process %d )\n"),
637c478bd9Sstevel@tonic-gate s, strsignal(sip->si_signo), sip->si_pid);
647c478bd9Sstevel@tonic-gate } else if (((listp = &_sys_siginfolist[sip->si_signo-1]) != NULL) &&
657c478bd9Sstevel@tonic-gate sip->si_code <= listp->nsiginfo) {
667c478bd9Sstevel@tonic-gate c = _libc_gettext(listp->vsiginfo[sip->si_code-1]);
677c478bd9Sstevel@tonic-gate switch (sip->si_signo) {
687c478bd9Sstevel@tonic-gate case SIGSEGV:
697c478bd9Sstevel@tonic-gate case SIGBUS:
707c478bd9Sstevel@tonic-gate case SIGILL:
717c478bd9Sstevel@tonic-gate case SIGFPE:
727c478bd9Sstevel@tonic-gate (void) snprintf(buf, sizeof (buf),
737c478bd9Sstevel@tonic-gate _libc_gettext("%s : %s ( [%p] %s)\n"),
747c478bd9Sstevel@tonic-gate s, strsignal(sip->si_signo),
757c478bd9Sstevel@tonic-gate sip->si_addr, c);
767c478bd9Sstevel@tonic-gate break;
777c478bd9Sstevel@tonic-gate default:
787c478bd9Sstevel@tonic-gate (void) snprintf(buf, sizeof (buf),
797c478bd9Sstevel@tonic-gate _libc_gettext("%s : %s (%s)\n"),
807c478bd9Sstevel@tonic-gate s, strsignal(sip->si_signo), c);
817c478bd9Sstevel@tonic-gate break;
827c478bd9Sstevel@tonic-gate }
837c478bd9Sstevel@tonic-gate } else {
847c478bd9Sstevel@tonic-gate (void) snprintf(buf, sizeof (buf),
857c478bd9Sstevel@tonic-gate _libc_gettext("%s : %s\n"),
867c478bd9Sstevel@tonic-gate s, strsignal(sip->si_signo));
877c478bd9Sstevel@tonic-gate }
887c478bd9Sstevel@tonic-gate (void) write(2, buf, strlen(buf));
897c478bd9Sstevel@tonic-gate }
90