linux-sysprog · beginner · ~15 min

Signal number to name

Translate a signal number back to a name.

Challenge

Implement const char *sig_name(int sig) returning "SIGINT", "SIGTERM", or "SIGKILL" for those signals, else "UNKNOWN".

Starter code

#include <signal.h>

const char *sig_name(int sig) {
    /* TODO */
    return "UNKNOWN";
}

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