linux/tools/testing/selftests/bpf/io_helpers.h
Eduard Zingerman 03066ed310 selftests/bpf: add read_with_timeout() utility function
int read_with_timeout(int fd, char *buf, size_t count, long usec)

As a regular read(2), but allows to specify a timeout in
micro-seconds. Returns -EAGAIN on timeout.
Implemented using select().

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20241112110906.3045278-3-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2024-11-12 13:53:27 -08:00

7 lines
234 B
C

// SPDX-License-Identifier: GPL-2.0
#include <unistd.h>
/* As a regular read(2), but allows to specify a timeout in micro-seconds.
* Returns -EAGAIN on timeout.
*/
int read_with_timeout(int fd, char *buf, size_t count, long usec);