explain_dirfd_or_die(3)
π explain_dirfd_or_die β the manual page, but make it make sense π
okay so bestie, you're here because you want the file descriptor of a directory stream, and you want it done with consequences. this is explain_dirfd_or_die(3), from the Library Functions Manual, and honestly? it's giving "I don't do silent failures." π
β¨ NAME β¨
explain_dirfd_or_die β grab that directory stream file descriptor, and if it goes wrong, we're gonna talk about it π’
πΈ SYNOPSIS πΈ
#include <libexplain/dirfd.h>
int explain_dirfd_or_die(DIR *dir);
int explain_dirfd_on_error(DIR *dir);
like. two functions. one of them is dramatic. you already know which. π
π¦ DESCRIPTION π¦
so explain_dirfd_or_die is the girl who wraps dirfd(3) for you. she calls the dirfd(3) system call, and if it fails? she prints an explanation to stderr (obtained from the explain_dirfd(3) function, no cap) and then she ends the whole process by calling exit(EXIT_FAILURE). no coming back from that. periodt. π
and then there's explain_dirfd_on_error, her chiller sister. she also calls the dirfd(3) system call, and on failure she also prints an explanation to stderr obtained from the explain_dirfd(3) function β but she still returns to you. she's not gonna ghost your process. she just tells you what happened and hands the problem back. π«Ά
dirβ the dir, exactly as to be passed to thedirfd(3)system call. don't get cute with it, just pass it through exactly. β¨
π RETURN VALUE π
explain_dirfd_or_die only returns on success β peep dirfd(3) if you want the details. on failure it prints an explanation and exits, meaning it does not return. at all. ever. that's the whole bit. π
explain_dirfd_on_error always returns the value return by the wrapped dirfd(3) system call. always. she's consistent like that. π
π EXAMPLE π
the explain_dirfd_or_die function is intended to be used in a fashion similar to the following example:
int result = explain_dirfd_or_die(dir);
see? iconic. one line. main character energy. π β¨
π SEE ALSO π
dirfd(3)β get directory stream file descriptorexplain_dirfd(3)β explaindirfd(3)errorsexit(2)β terminate the calling process
π COPYRIGHT π
libexplain version 1.4Copyright (C) 2009 Peter Miller
and that's the whole page bestie, you ate π go forth and get that directory stream file descriptor, and remember: if it fails, at least it'll fail loudly. bye babes π¦πΈβ¨
π¦ 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