1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

LibC: Move getsignalbyname() helper from Userland/kill into LibC

This commit is contained in:
Andreas Kling 2020-10-29 11:49:24 +01:00
parent a6b2598fba
commit ad0295d033
3 changed files with 51 additions and 49 deletions

View file

@ -39,55 +39,6 @@ static void print_usage_and_exit()
exit(1);
}
static const char* signal_names[] = {
"INVAL",
"HUP",
"INT",
"QUIT",
"ILL",
"TRAP",
"ABRT",
"BUS",
"FPE",
"KILL",
"USR1",
"SEGV",
"USR2",
"PIPE",
"ALRM",
"TERM",
"STKFLT",
"CHLD",
"CONT",
"STOP",
"TSTP",
"TTIN",
"TTOU",
"URG",
"XCPU",
"XFSZ",
"VTALRM",
"PROF",
"WINCH",
"IO",
"INFO",
"SYS"
};
static_assert(sizeof(signal_names) == sizeof(const char*) * 32);
int getsignalbyname(const char* name)
{
ASSERT(name);
for (size_t i = 0; i < NSIG; ++i) {
auto* signal_name = signal_names[i];
if (!strcmp(signal_name, name))
return i;
}
errno = EINVAL;
return -1;
}
int main(int argc, char** argv)
{
if (pledge("stdio proc", nullptr) < 0) {