io_uring_prep_pipe(3)

✨ io_uring_prep_pipe β€” prepare a pipe creation request ✨

okay bestie, this one is from the liburing manual, and it's literally just the girlies setting up a pipe request πŸ’…


🌸 SYNOPSIS 🌸

#include <liburing.h>

void io_uring_prep_pipe(struct io_uring_sqe *sqe,
                        int *fds,
                        int pipe_flags);

void io_uring_prep_pipe_direct(struct io_uring_sqe *sqe,
                               int *fds,
                               int pipe_flags,
                               unsigned int file_index);

πŸ¦‹ DESCRIPTION πŸ¦‹

So io_uring_prep_pipe(3) prepares a pipe creation request. The submission queue entry sqe gets set up to create a pipe, the freshly created descriptors get copied into the array pointed at by fds, and pipe_flags is used as the pipe creation flags. Wanna know which flags are valid? Run, don't walk, to pipe2(2) β€” it's all there πŸ’–

Now io_uring_prep_pipe_direct(3) is the same vibe, but it uses fixed/registered file descriptors instead of the normal kind. This one takes an extra file_index argument, and you've got options, queen:

  • set it to an explicit direct descriptor offset where you want the two pipe file descriptors to live, or
  • set it to IORING_FILE_INDEX_ALLOC and let io_uring pick any available descriptors for the read and write side of the pipe πŸŽ€

If you do hand it a specific index, the read side of the pipe gets created at that offset (if it's free, obvi), and the write side goes at the next one β€” that's +1 index, babes. Both of those slots need to be currently unused, or the whole operation just fails 😭. Also if you want the tea on the file_index parameter itself, go read io_uring_prep_accept_direct(3) or io_uring_prep_socket_direct(3) 🫢

For both the direct and the normal file descriptor pipe request: once the request completes successfully, the resulting input/read side of the pipe lands in fds[0] and the output/write side lands in fds[1]. Periodt ✨

This function prepares an async pipe2(2) request. See that man page for the details, bestie.


πŸ‘‘ RETURN VALUE πŸ‘‘

None. Like, literally nothing. She gives you nothing back πŸ’€


πŸ’€ ERRORS πŸ’€

The CQE res field is where the result of the operation shows up. Check the related man page for what the possible values could be.

Heads up! Where synchronous system calls would 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. Different system, different rules, no cap πŸ™ˆ

🌈 SEE ALSO 🌈


mwah πŸ’œ that's the whole page! this icon was brought to you by liburing-2.10, dated April 8, 2025, and she ate, fr fr πŸŽ€βœ¨

πŸ“¦ where this page comes from