1str2sig(3C)              Standard C Library Functions              str2sig(3C)
2
3
4

NAME

6       str2sig, sig2str - translation between signal name and signal number
7

SYNOPSIS

9       #include <signal.h>
10
11       int str2sig(const char *str, int *signum);
12
13
14       int sig2str(int signum, char *str);
15
16

DESCRIPTION

18       The  str2sig() function translates the signal name str to a signal num‐
19       ber, and stores that result in the location referenced by  signum.  The
20       name in str can be either the symbol for that signal, without the "SIG"
21       prefix, or a  decimal  number.   All  the  signal  symbols  defined  in
22       <sys/signal.h>  are  recognized.  This means that both "CLD" and "CHLD"
23       are recognized and return the same signal number, as do both "POLL" and
24       "IO".  For access to the signals in the range SIGRTMIN to SIGRTMAX, the
25       first four signals match the strings "RTMIN", "RTMIN+1", "RTMIN+2", and
26       "RTMIN+3"  and  the  last  four match the strings "RTMAX-3", "RTMAX-2",
27       "RTMAX-1", and "RTMAX".
28
29
30       The sig2str() function translates the signal number signum to the  sym‐
31       bol  for  that signal, without the "SIG" prefix, and stores that symbol
32       at the location specified by str. The storage referenced by str  should
33       be  large  enough  to  hold the symbol and a terminating null byte. The
34       symbol SIG2STR_MAX defined by <signal.h>  gives  the  maximum  size  in
35       bytes required.
36

RETURN VALUES

38       The str2sig() function returns 0 if it recognizes the signal name spec‐
39       ified in str; otherwise, it returns −1.
40
41
42       The sig2str() function returns 0 if the value signum corresponds  to  a
43       valid signal number; otherwise, it returns −1.
44

EXAMPLES

46       Example 1 A sample program using the str2sig() function.
47
48         int i;
49         char buf[SIG2STR_MAX];     /*storage for symbol */
50
51         str2sig("KILL",&i);        /*stores 9 in i */
52         str2sig("9", &i);          /* stores 9 in i */
53         sig2str(SIGKILL,buf);      /* stores "KILL" in buf */
54         sig2str(9,buf);            /* stores "KILL" in buf */
55
56
57

SEE ALSO

59       kill(1), strsignal(3C)
60
61
62
63SunOS 5.11                        7 Oct 1999                       str2sig(3C)
Impressum