explain_poll_or_die(3)
β¨ explain_poll_or_die(3) β¨
okay bestie, sit down, hydrate, because we're talking about explain_poll_or_die β a lil library function that hangs out in the Library Functions Manual and is here to wait for events on a file descriptor and then tell you all about it when things go wrong π
π NAME π
explain_poll_or_die β wait for some event on file descriptor and report errors
no cap, that's literally the whole job description π«Ά
πΈ SYNOPSIS πΈ
#include <libexplain/poll.h>
int explain_poll_or_die(struct pollfd *fds, int nfds, int timeout);
int explain_poll_on_error(struct pollfd *fds, int nfds, int timeout);
two functions, one header, zero drama (well... some drama, it's in the name) β¨
π DESCRIPTION π
so. explain_poll_or_die is the function you call when you want to call the poll(2) system call. and if that call fails? it prints an explanation straight to stderr β and that explanation comes from the explain_poll(3) function β and then it terminates the process by calling exit(EXIT_FAILURE). yeah. it does not play. it's giving "or die" and it MEANS it π
meanwhile explain_poll_on_error is the chill sibling π β it also calls the poll(2) system call, and on failure it also prints an explanation to stderr (again, from explain_poll(3))... but then it still returns to the caller. no exiting. no quitting. it just comes back and hands you the news π
now, the args, and yes they're all passed through exactly as-is:
fdsβ the fds, exactly as to be passed to thepoll(2)system call. no edits, no glow-up, straight through π¦nfdsβ the nfds, exactly as to be passed to thepoll(2)system call. periodt.timeoutβ the timeout, exactly as to be passed to thepoll(2)system call. it's the vibe check timer fr fr β
π RETURN VALUE π
explain_poll_or_die only returns on success β peep poll(2) for more info on that. on failure it prints an explanation and exits, which means... it does not return. like, at all. it's gone. departed. βοΈπ
explain_poll_on_error always returns the value returned by the wrapped poll(2) system call. every time. it always comes home π«Ά
π§ EXAMPLE π§
this is how the cool kids use explain_poll_or_die:
int result = explain_poll_or_die(fds, nfds, timeout);
one line, one call, main character energy π
π SEE ALSO π
poll(2)β wait for some event on a file descriptorexplain_poll(3)β explainpoll(2)errorsexit(2)β terminate the calling process
π COPYRIGHT π
this whole thing is libexplain version 1.4, and the copyright belongs to Copyright (C) 2010 Peter Miller.
and that's the page bestie!! π iykyk β go forth, poll responsibly, and remember: explain_poll_or_die only returns on success, so if you get a return value, you ATE π β¨ π¦πΈπ
π¦ 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) 2010, 2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms