psignal.c revision 56698
1190214Srpaulo/*
2190214Srpaulo * Copyright (c) 1983, 1993
3190214Srpaulo *	The Regents of the University of California.  All rights reserved.
4190214Srpaulo *
5190214Srpaulo * Redistribution and use in source and binary forms, with or without
6190214Srpaulo * modification, are permitted provided that the following conditions
7190214Srpaulo * are met:
8190214Srpaulo * 1. Redistributions of source code must retain the above copyright
9190214Srpaulo *    notice, this list of conditions and the following disclaimer.
10190214Srpaulo * 2. Redistributions in binary form must reproduce the above copyright
11190214Srpaulo *    notice, this list of conditions and the following disclaimer in the
12190214Srpaulo *    documentation and/or other materials provided with the distribution.
13190214Srpaulo * 3. All advertising materials mentioning features or use of this software
14190214Srpaulo *    must display the following acknowledgement:
15190214Srpaulo *	This product includes software developed by the University of
16190214Srpaulo *	California, Berkeley and its contributors.
17190214Srpaulo * 4. Neither the name of the University nor the names of its contributors
18190214Srpaulo *    may be used to endorse or promote products derived from this software
19190214Srpaulo *    without specific prior written permission.
20190214Srpaulo *
21190214Srpaulo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22190214Srpaulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23190214Srpaulo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24190214Srpaulo * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25190214Srpaulo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26190214Srpaulo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27190214Srpaulo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28190214Srpaulo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29190214Srpaulo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30190214Srpaulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31190214Srpaulo * SUCH DAMAGE.
32190214Srpaulo *
33190214Srpaulo * $FreeBSD: head/lib/libc/gen/psignal.c 56698 2000-01-27 23:07:25Z jasone $
34190214Srpaulo */
35190214Srpaulo
36190214Srpaulo#if defined(LIBC_SCCS) && !defined(lint)
37190214Srpaulostatic char sccsid[] = "@(#)psignal.c	8.1 (Berkeley) 6/4/93";
38190214Srpaulo#endif /* LIBC_SCCS and not lint */
39190214Srpaulo
40190214Srpaulo/*
41190214Srpaulo * Print the name of the signal indicated
42190214Srpaulo * along with the supplied message.
43190214Srpaulo */
44190214Srpaulo#include <signal.h>
45190214Srpaulo#include <string.h>
46190214Srpaulo#include <unistd.h>
47190214Srpaulo
48190214Srpaulovoid
49190214Srpaulopsignal(sig, s)
50190214Srpaulo	unsigned int sig;
51190214Srpaulo	const char *s;
52190214Srpaulo{
53190214Srpaulo	register const char *c;
54190214Srpaulo
55190214Srpaulo	if (sig < NSIG)
56190214Srpaulo		c = sys_siglist[sig];
57190214Srpaulo	else
58190214Srpaulo		c = "Unknown signal";
59190214Srpaulo	if (s != NULL && *s != '\0') {
60190214Srpaulo		(void)_write(STDERR_FILENO, s, strlen(s));
61190214Srpaulo		(void)_write(STDERR_FILENO, ": ", 2);
62190214Srpaulo	}
63190214Srpaulo	(void)_write(STDERR_FILENO, c, strlen(c));
64190214Srpaulo	(void)_write(STDERR_FILENO, "\n", 1);
65190214Srpaulo}
66190214Srpaulo