linux-sysprog · beginner · ~15 min

Signal name to number

Translate a signal name to its number.

Challenge

Implement int sig_number(const char *name) mapping "SIGINT", "SIGTERM", "SIGKILL" to their constants, or -1 for anything else.

Starter code

#include <signal.h>
#include <string.h>

int sig_number(const char *name) {
    /* TODO */
    return -1;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.