explain_kill(3)
πΈ explain_kill β the manual page, but make it make sense π
okay so this is explain_kill(3), a Library Functions Manual page, and bestie it is so useful. it's all about turning those cursed kill(2) errors into actual human words. let's get into it β¨
β¨ NAME β¨
explain_kill β explain kill(2) errors π©·
π SYNOPSIS π
#include <libexplain/kill.h>
const char *explain_kill(pid_t pid, int sig);
const char *explain_errno_kill(int errnum, pid_t pid, int sig);
void explain_message_kill(char *message, int message_size, pid_t pid,
int sig);
void explain_message_errno_kill(char *message, int message_size, int
errnum, pid_t pid, int sig);
π DESCRIPTION π
these functions? they exist so you can get explanations for errors that the kill(2) system call throws at you. no more staring at a cryptic failure like ποΈπποΈ
π¦ explain_kill
const char *explain_kill(pid_t pid, int sig);
the explain_kill function grabs you an explanation of an error returned by the kill(2) system call. the least it'll give you is the value of strerror(errno), but honestly? usually it goes way harder and tells you the actual underlying cause in way more detail. iconic behaviour fr fr π
the errno global variable is what gets used to obtain the error value to be decoded.
pidβ the originalpid, exactly as passed to thekill(2)system call. no edits, no remixes.sigβ the originalsig, exactly as passed to thekill(2)system call. same energy.
Returns: the message explaining the error. β οΈ this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function that shares this buffer β including other threads. so yeah, don't hold onto it like it's yours.
Note: this function is not thread safe, because it shares a return buffer across all threads, and so do many other functions in this library. not me writing multithreaded code with this π
Example: this function is meant to be used in a fashion similar to the following example:
if (kill(pid, sig) < 0)
{
fprintf(stderr, "%s\n", explain_kill(pid, sig));
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_kill_or_die(3) function. so convenient, we love her π«Ά
π explain_errno_kill
const char *explain_errno_kill(int errnum, pid_t pid, int sig);
the explain_errno_kill function gets you an explanation of an error returned by the kill(2) system call. the least the message will contain is the value of strerror(errno), but usually it does much better and points at the underlying cause in more detail. slay β¨
errnumβ the error value to be decoded, usually grabbed from theerrnoglobal variable right before this function is called. this is necessary if you need to call any code between the system call you're explaining and this function, because sooo many libc functions will mess with the value oferrno. like they will simply alter it. rude.pidβ the originalpid, exactly as passed to thekill(2)system call.sigβ the originalsig, exactly as passed to thekill(2)system call.
Returns: the message explaining the error. β οΈ this message buffer is shared by all libexplain functions which don't supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library too. π
Example: this function is intended to be used in a fashion similar to the following example:
if (kill(pid, sig) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_kill(err, pid, sig));
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_kill_or_die(3) function. π
π§ explain_message_kill
void explain_message_kill(char *message, int message_size, pid_t pid,
int sig);
the explain_message_kill function gets you an explanation of an error returned by the kill(2) system call. the least the message will contain is the value of strerror(errno), but usually it does much better and shows the underlying cause in more detail. no cap πΈ
the errno global variable will be used to obtain the error value to be decoded.
messageβ the location in which to store the returned message. if you supply a suitable message return buffer, this function is thread safe. okayyy we love a thread-safe moment πmessage_sizeβ the size in bytes of the location in which to store the returned message.pidβ the originalpid, exactly as passed to thekill(2)system call.sigβ the originalsig, exactly as passed to thekill(2)system call.
Example: this function is intended to be used in a fashion similar to the following example:
if (kill(pid, sig) < 0)
{
char message[3000];
explain_message_kill(message, sizeof(message), pid, sig);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_kill_or_die(3) function. π
π explain_message_errno_kill
void explain_message_errno_kill(char *message, int message_size, int
errnum, pid_t pid, int sig);
the explain_message_errno_kill function gets you an explanation of an error returned by the kill(2) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better and indicate the underlying cause in more detail. periodt π
messageβ the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe. main character energy fr.message_sizeβ the size in bytes of the location in which to store the returned message.errnumβ the error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. they're always doing the most πpidβ the originalpid, exactly as passed to thekill(2)system call.sigβ the originalsig, exactly as passed to thekill(2)system call.
Example: this function is intended to be used in a fashion similar to the following example:
if (kill(pid, sig) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_kill(message, sizeof(message), err,
pid, sig);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_kill_or_die(3) function. β
π₯ SEE ALSO π₯
kill(2)β send signal to a processexplain_kill_or_die(3)β send signal to a process and report errors
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2009 Peter Miller
and that's the whole page bestie π¦ go forth and explain your errors, you got this. iykyk π
~ with love, from the explain_kill(3) page in the Library Functions Manual ~ π
π¦ where this page comes from
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2009-2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms