1 /* Copyright 2002, 2011 Red Hat Inc. */
2 /*
3 FUNCTION
4 <<psignal>>---print a signal message on standard error
5 
6 INDEX
7 	psignal
8 
9 SYNOPSIS
10 	#include <stdio.h>
11 	void psignal(int <[signal]>, const char *<[prefix]>);
12 
13 DESCRIPTION
14 Use <<psignal>> to print (on standard error) a signal message
15 corresponding to the value of the signal number <[signal]>.
16 Unless you use <<NULL>> as the value of the argument <[prefix]>, the
17 signal message will begin with the string at <[prefix]>, followed by a
18 colon and a space (<<: >>). The remainder of the signal message is one
19 of the strings described for <<strsignal>>.
20 
21 RETURNS
22 <<psignal>> returns no result.
23 
24 PORTABILITY
25 POSIX.1-2008 requires <<psignal>>, but the strings issued vary from one
26 implementation to another.
27 
28 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
29 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
30 */
31 
32 #define _DEFAULT_SOURCE
33 #include <_ansi.h>
34 #include <stdio.h>
35 #include <string.h>
36 #include <unistd.h>
37 
38 void
psignal(int sig,const char * s)39 psignal (int sig,
40        const char *s)
41 {
42   fflush (stderr);
43   if (s != NULL && *s != '\0')
44       fprintf(stderr, "%s: ", s);
45   fprintf(stderr, "%s\n", strsignal(sig));
46 }
47