mirror of
https://github.com/troglobit/finit.git
synced 2026-10-20 11:19:35 +00:00
initctl signal command parsing: done
This commit is contained in:
1 parent
3c9053b055
commit
62da379472
6 files changed
+135
-37
No files matched your search
+28
@@ -275,6 +275,34 @@ char *sig2str(int sig)
|
||||
return signame;
|
||||
}
|
||||
|
||||
/**
|
||||
* str2sig - Translate signal name to the corresponding signal number.
|
||||
* @sig: The name of the signal
|
||||
*
|
||||
* A signal can be a complete signal name such as "SIGHUP", or
|
||||
* it can be the shortest unique name, such as "HUP" (no SIG prefix).
|
||||
*/
|
||||
int str2sig(char *sig)
|
||||
{
|
||||
int name_offset = 0;
|
||||
size_t i;
|
||||
|
||||
/* if sig name starts with "SIG", then skip the first
|
||||
* three characters. signames holds the names without
|
||||
* the "SIG" prefix.
|
||||
*/
|
||||
if (strncasecmp(sig, "SIG", 3) == 0) {
|
||||
name_offset = 3;
|
||||
}
|
||||
|
||||
for (i = 1; i < NELEMS(signames); ++i) {
|
||||
if (strcasecmp(&sig[name_offset], signames[i]) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *code2str(int code)
|
||||
{
|
||||
static char codename[20];
|
||||
|
||||
Reference in new issue
Block a user