xref: /csrg-svn/lib/libc/gen/psignal.c (revision 61111)
110901Ssam /*
2*61111Sbostic  * Copyright (c) 1983, 1993
3*61111Sbostic  *	The Regents of the University of California.  All rights reserved.
435285Sbostic  *
542625Sbostic  * %sccs.include.redist.c%
621353Sdist  */
721353Sdist 
826576Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*61111Sbostic static char sccsid[] = "@(#)psignal.c	8.1 (Berkeley) 06/04/93";
1035285Sbostic #endif /* LIBC_SCCS and not lint */
1121353Sdist 
1221353Sdist /*
1310901Ssam  * Print the name of the signal indicated
1410901Ssam  * along with the supplied message.
1510901Ssam  */
1645646Sbostic #include <sys/signal.h>
1746597Sdonn #include <string.h>
1845646Sbostic #include <unistd.h>
1910901Ssam 
2046597Sdonn void
psignal(sig,s)2110901Ssam psignal(sig, s)
2235285Sbostic 	unsigned int sig;
2346597Sdonn 	const char *s;
2410901Ssam {
2560034Storek 	register const char *c;
2635285Sbostic 	register int n;
2710901Ssam 
2810901Ssam 	if (sig < NSIG)
2910901Ssam 		c = sys_siglist[sig];
3035285Sbostic 	else
3135285Sbostic 		c = "Unknown signal";
3210901Ssam 	n = strlen(s);
3310901Ssam 	if (n) {
3445646Sbostic 		(void)write(STDERR_FILENO, s, n);
3545646Sbostic 		(void)write(STDERR_FILENO, ": ", 2);
3610901Ssam 	}
3745646Sbostic 	(void)write(STDERR_FILENO, c, strlen(c));
3845646Sbostic 	(void)write(STDERR_FILENO, "\n", 1);
3910901Ssam }
40