4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
36 #include <sys/types.h>
39 typedef struct signame
{
44 static signame_t signames
[] = {
67 { "WINCH", SIGWINCH
},
76 { "VTALRM", SIGVTALRM
},
80 { "WAITING", SIGWAITING
},
82 { "FREEZE", SIGFREEZE
},
84 { "CANCEL", SIGCANCEL
},
89 { "RTMIN", _SIGRTMIN
},
90 { "RTMIN+1", _SIGRTMIN
+1 },
91 { "RTMIN+2", _SIGRTMIN
+2 },
92 { "RTMIN+3", _SIGRTMIN
+3 },
93 { "RTMAX-3", _SIGRTMAX
-3 },
94 { "RTMAX-2", _SIGRTMAX
-2 },
95 { "RTMAX-1", _SIGRTMAX
-1 },
96 { "RTMAX", _SIGRTMAX
},
99 #define SIGCNT (sizeof (signames) / sizeof (struct signame))
101 static int str2long(const char *, long *);
104 str2long(const char *p
, long *val
)
108 int saved_errno
= errno
;
111 *val
= strtol(p
, &q
, 10);
113 error
= ((errno
!= 0 || q
== p
|| *q
!= '\0') ? -1 : 0);
120 str2sig(const char *s
, int *sigp
)
122 const struct signame
*sp
;
124 if (*s
>= '0' && *s
<= '9') {
127 if (str2long(s
, &val
) == -1)
130 for (sp
= signames
; sp
< &signames
[SIGCNT
]; sp
++) {
131 if (sp
->signum
== val
) {
138 for (sp
= signames
; sp
< &signames
[SIGCNT
]; sp
++) {
139 if (strcmp(sp
->sigstr
, s
) == 0) {
149 sig2str(int i
, char *s
)
151 const struct signame
*sp
;
153 for (sp
= signames
; sp
< &signames
[SIGCNT
]; sp
++) {
154 if (sp
->signum
== i
) {
155 (void) strcpy(s
, sp
->sigstr
);