Skip to content

Commit

Permalink
waitid: add io_uring flags parameter
Browse files Browse the repository at this point in the history
Let's future proof this a bit and have the flags exposed, so that this
prep helper will remain constant if we do decide to add some flags at
a later time.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 18, 2023
1 parent ea4e460 commit ceb4ff6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
7 changes: 6 additions & 1 deletion man/io_uring_prep_waitid.3
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ io_uring_prep_waitid \- prepare a waitid request
.BI " idtype_t " idtype ","
.BI " id_t " id ","
.BI " siginfo_t *" infop ","
.BI " int " options ");"
.BI " int " options ","
.BI " unsigned int " flags ");"
.fi
.SH DESCRIPTION
.PP
Expand All @@ -32,6 +33,10 @@ to specify the child state changes to wait for. Upon successful
return, it fills
.I infop
with information of the child process, if any.
.I flags
is io_uring specific modifier flags. They are currently unused, and hence
.B 0
should be passed.

This function prepares an async
.BR waitid (2)
Expand Down
3 changes: 2 additions & 1 deletion src/include/liburing.h
Original file line number Diff line number Diff line change
Expand Up @@ -1166,9 +1166,10 @@ IOURINGINLINE void io_uring_prep_waitid(struct io_uring_sqe *sqe,
idtype_t idtype,
id_t id,
siginfo_t *infop,
int options)
int options, unsigned int flags)
{
io_uring_prep_rw(IORING_OP_WAITID, sqe, id, NULL, (unsigned) idtype, 0);
sqe->waitid_flags = flags;
sqe->file_index = options;
sqe->addr2 = (unsigned long) infop;
}
Expand Down
12 changes: 6 additions & 6 deletions test/waitid.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int test_noexit(struct io_uring *ring)
}

sqe = io_uring_get_sqe(ring);
io_uring_prep_waitid(sqe, P_PID, pid, &si, WEXITED);
io_uring_prep_waitid(sqe, P_PID, pid, &si, WEXITED, 0);
sqe->flags |= IOSQE_IO_LINK;
sqe->user_data = 1;

Expand Down Expand Up @@ -96,7 +96,7 @@ static int test_double(struct io_uring *ring)
}

sqe = io_uring_get_sqe(ring);
io_uring_prep_waitid(sqe, P_PID, p2, &si, WEXITED);
io_uring_prep_waitid(sqe, P_PID, p2, &si, WEXITED, 0);

io_uring_submit(ring);

Expand Down Expand Up @@ -137,7 +137,7 @@ static int test_ready(struct io_uring *ring)
}

sqe = io_uring_get_sqe(ring);
io_uring_prep_waitid(sqe, P_PID, pid, &si, WEXITED);
io_uring_prep_waitid(sqe, P_PID, pid, &si, WEXITED, 0);

io_uring_submit(ring);

Expand Down Expand Up @@ -177,7 +177,7 @@ static int test_cancel(struct io_uring *ring)
}

sqe = io_uring_get_sqe(ring);
io_uring_prep_waitid(sqe, P_PID, pid, NULL, WEXITED);
io_uring_prep_waitid(sqe, P_PID, pid, NULL, WEXITED, 0);
sqe->user_data = 1;

io_uring_submit(ring);
Expand Down Expand Up @@ -228,7 +228,7 @@ static int test_cancel_race(struct io_uring *ring, int async)
}

sqe = io_uring_get_sqe(ring);
io_uring_prep_waitid(sqe, P_ALL, -1, NULL, WEXITED);
io_uring_prep_waitid(sqe, P_ALL, -1, NULL, WEXITED, 0);
if (async)
sqe->flags |= IOSQE_ASYNC;
sqe->user_data = 1;
Expand Down Expand Up @@ -284,7 +284,7 @@ static int test(struct io_uring *ring)
}

sqe = io_uring_get_sqe(ring);
io_uring_prep_waitid(sqe, P_PID, pid, &si, WEXITED);
io_uring_prep_waitid(sqe, P_PID, pid, &si, WEXITED, 0);

io_uring_submit(ring);

Expand Down

0 comments on commit ceb4ff6

Please sign in to comment.