mailing list of musl libc
 help / color / mirror / code / Atom feed
b6a4fc239634f76f5f628bf0b13bc36d6c31668e blob 1178 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
#include <signal.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>

int str2sig(const char *restrict str, int *restrict pnum)
{
	if (str[0] == '\0') return -1;

	errno = 0;
	long signum = strtol(str, NULL, 10);
	if (errno == 0 && signum < _NSIG) return (*pnum = signum, 0);

	if (strnlen(str, sizeof *__sys_signame) <= sizeof *__sys_signame)
		for (int i = 0; i < sizeof __sys_signame/sizeof *__sys_signame; i++)
			if (strncmp(str, __sys_signame[i], sizeof *__sys_signame) == 0)
				return (*pnum = i, 0);

	// signal aliases
	if (strcmp(str, "IOT") == 0)
		return (*pnum = SIGIOT, 0);
	if (strcmp(str, "UNUSED") == 0)
		return (*pnum = SIGUNUSED, 0);
#if SIGPOLL != SIGIO
	if (strcmp(str, "POLL") == 0)
		return (*pnum = SIGPOLL, 0);
#endif

	if (strcmp(str, "RTMIN") == 0)
		return (*pnum = SIGRTMIN, 0);
	if (strcmp(str, "RTMAX") == 0)
		return (*pnum = SIGRTMAX, 0);

	if (strncmp(str, "RTMIN+", 6) == 0 || strncmp(str, "RTMAX-", 6) == 0)
	{
		errno = 0;
		long sigrt = strtol(str+6, NULL, 10);
		if(errno != 0 || sigrt < 1 || sigrt > SIGRTMAX - SIGRTMIN) return -1;

		*pnum = str[5] == '+' ? SIGRTMIN + sigrt : SIGRTMAX - sigrt;
		return 0;
	}

	return -1;
}
debug log:

solving b6a4fc23 ...
found b6a4fc23 in https://inbox.vuxu.org/musl/20240805065607.22897-3-contact@hacktivis.me/

applying [1/1] https://inbox.vuxu.org/musl/20240805065607.22897-3-contact@hacktivis.me/
diff --git a/src/signal/str2sig.c b/src/signal/str2sig.c
new file mode 100644
index 00000000..b6a4fc23

Checking patch src/signal/str2sig.c...
Applied patch src/signal/str2sig.c cleanly.

index at:
100644 b6a4fc239634f76f5f628bf0b13bc36d6c31668e	src/signal/str2sig.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).