Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / allreadwrite.h / fd_read.3.md

% limb manual
% fd_read(3)
% limb 0.1.0
% 2023-07-24

# NAME

fd_read, fd_readv - safe wrappers for reading files

# SYNOPSIS

    #include <limb/allreadwrite.h>

```pre hl
ssize_t fd_read(int <em>fd</em>, char *<em>dst</em>, size_t <em>dlen</em>)
ssize_t fd_readv(int <em>fd</em>, const struct iovec *<em>v</em>, unsigned <em>n</em>)
```

# DESCRIPTION

The `fd_read`() function is a safe wrapper around [read](3), i.e. it cannot be
interrupted by signals. More precisely, if [read](3) fails with *EINTR* it is
automatically called again until it succeeds or fails with another error.

The `fd_readv`() function is similar, but around [readv](3).

# RETURN VALUE

These functions return the number of bytes read from `fd` and copied into memory
on success. Otherwise they return -1 and set `errno` to indicate the error.

# ERRORS

The `fd_read`() and `fd_readv`() functions may fail and set `errno` for any of
the errors described for [read](3) and [readv](3), respectively, except for
*EINTR*.