ABORT2(2)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… ABORT2(2) β€” System Calls Manual, but make it group-chat πŸ’…

Okay bestie, welcome to ABORT2(2) from the System Calls Manual β€” this is the abort2 page and it's lowkey iconic for a very specific reason: it's the "take me out with a diagnostic message" syscall. Periodt.

✨ NAME ✨

abort2 β€” abort process with diagnostics. No cap, that's the whole vibe.

🫢 LIBRARY 🫢

You get this glow-up from the Standard C Library (libc, -lc). Slay.

🌸 SYNOPSIS 🌸

#include <stdlib.h>

void
abort2(const char *why, int nargs, void **args);

πŸ’– DESCRIPTION πŸ’–

Okay so the abort2() system call causes the process to be killed, and the specified diagnostic message (with arguments) gets delivered by the kernel to the syslogd(8) daemon. Literally kernel-delivered diagnostics, which is the main character energy here.

The why argument points to a NUL-terminated string specifying a reason of the program's termination (maximum 128 characters long). The args array contains pointers which will be logged numerically (with the kernel's β€˜%p’ printf(9) format). The nargs argument specifies the number of pointers in args (maximum 16).

The abort2() system call is intended for use in situations where continuation of a process is impossible or where, for other definitive reasons, it is unwanted, and normal diagnostic channels cannot be trusted to deliver the message. It's giving "last words, but make them reliable."

⚠️ RETURN VALUES ⚠️

The abort2() function never returns. Not me crying, it literally never returns.

The process is killed with SIGABRT unless the arguments to abort2() are invalid, in which case SIGKILL is used. Vibe check failed? SIGKILL says bye.

πŸͺ EXAMPLES πŸͺ

Here's the example, copied exactly because we do not play with code:

#include <stdlib.h>

if (weight_kg > max_load) {
        void *ptrs[3];

        ptrs[0] = (void *)(intptr_t)weight_kg;
        ptrs[1] = (void *)(intptr_t)max_load;
        ptrs[2] = haystack;
        abort2("Camel overloaded", 3, ptrs);
}

Camel overloaded is sending me πŸ’€. The example says what it says, bestie.

πŸ‘€ SEE ALSO πŸ‘€

πŸ¦‹ HISTORY πŸ¦‹

The abort2() system call first appeared in FreeBSD 7.0. Historical queen behavior.

πŸ‘‘ AUTHORS πŸ‘‘

The abort2() system call was designed by Poul-Henning Kamp <phk@FreeBSD.org>. It was implemented by Wojciech A. Koszek <dunstan@freebsd.czest.pl>. Obsessed with the collab, honestly.

🏁 Cute sign-off: Debian, September 30, 2006 β€” ABORT2(2) out, bestie! πŸ’–

πŸ“¦ where this page comes from