io_uring_prep_poll_add(3)
π io_uring_prep_poll_add β prepare a poll request π
okay bestie, come sit with me, we're doing liburing today and honestly? this one is so fun. it's from the liburing manual, and it's giving "let me watch this file descriptor for you, no biggie" energy. β¨
β¨ SYNOPSIS β¨
#include <poll.h>
#include <liburing.h>
void io_uring_prep_poll_add(struct io_uring_sqe *sqe,
int fd,
unsigned poll_mask);
void io_uring_prep_poll_multishot(struct io_uring_sqe *sqe,
int fd,
unsigned poll_mask);
like, two little functions, same shape, very demure, very mindful. π
πΈ DESCRIPTION πΈ
so. io_uring_prep_poll_add(3) prepares a poll request, periodt. what it does is it sets up the submission queue entry sqe to poll the file descriptor fd, and the events you're thirsting after get specified in that poll_mask argument. that's it, that's the whole vibe check. π¦
the default behavior is a single-shot poll request. the way that works: once the event you asked for has triggered, a completion CQE gets posted, and then... nothing. no more events will be generated by that poll request. it did its one job and it clocked out. π
io_uring_prep_poll_multishot(3) behaves identically in terms of events, but bestie, it persists across notifications. it will repeatedly post notifications for the same registration. it's the gift that keeps on giving, no cap. π₯
a CQE posted from a multishot poll request will have IORING_CQE_F_MORE set in the CQE flags member. that flag is basically the kernel telling you "there's more where that came from" β the application should expect more completions from this request. π
but listen, this part matters: if the multishot poll request gets terminated or experiences an error, that flag will not be set in the CQE. if that happens, the application should not expect further CQEs from the original request, and it must reissue a new one if it still wishes to get notifications on this file descriptor. no flag = the saga is over, you have to start a fresh request yourself. π
β RETURN VALUE β
None. nothing. void. it prepares and it dips. π
π ERRORS π
the CQE res field will contain the result of the operation, which is a bitmask of the events notified β go check the poll(2) man page for the deets, iykyk.
and here's the glow-up you need to internalize: where synchronous system calls will return -1 on failure and set errno to the actual error value, io_uring never uses errno. instead it returns the negated errno directly in the CQE res field. so like, stop checking errno, she doesn't live here anymore. π«Ά
π SEE ALSO π
io_uring_get_sqe(3)io_uring_submit(3)poll(2)epoll_ctl(3)
mwah π that was liburing-2.2, dated March 12, 2022 β and yes she's still iconic. go forth and poll something, bestie. π§β¨
π¦ where this page comes from
- alpine 3.22: liburing-doc 2.9-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.23: liburing-doc 2.12-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.24: liburing-doc 2.14-r0 Β· LGPL-2.1-or-later OR MIT
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- centos-stream 10: liburing-devel 2.12-1.el10 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- debian trixie: liburing-dev 2.9-1
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- nixpkgs unstable: liburing 2.14
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- ubuntu questing: liburing-dev 2.11-1
- ubuntu resolute: liburing-dev 2.14-1
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms