Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / djbunix.h / open2.3.md

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

# NAME

open2, open2_at, open3, open3_at - wrappers around open that can't be
interrupted by signals

# SYNOPSIS

    #include <limb/djbunix.h>

```pre hl
int open2(const char *<em>file</em>, unsigned <em>flags</em>)
int open3(const char *<em>file</em>, unsigned <em>flags</em>, unsigned <em>mode</em>)

int open2_at(int <em>fd</em>, const char *<em>file</em>, int <em>flags</em>)
int open3_at(int <em>fd</em>, const char *<em>file</em>, int <em>flags</em>, unsigned <em>mode</em>)
```

# DESCRIPTION

The `open2`() function is a wrapper around [open](2) that takes 2 arguments, and
cannot be interrupted by signals, i.e. if [open](3) fails with *EINTR* a new
call is automatically being made until it either succeeds or fails with a
different error.

The `open3`() function is similar to `open2`() only it takes a third argument.

The `open2_at`() function is similar to `open2`() except when `file` is a
relative path, in which case it is relative to the directory associated with the
file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

The `open3_at`() function is similar to `open3`() except when `file` is a
relative path, in which case it is relative to the directory associated with the
file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

# RETURN VALUE

Upon successful completion, these functions return the file descriptor
associated with the opened file. Otherwise they return -1 and set `errno` to
indicate the error.

# ERRORS

The `open2`() and `open3`() functions may fail and set `errno` for any of the
errors specified for [open](3).

The `open2_at`() and `open3_at`() functions may fail and set `errno` for any of
the errors specified for [openat](3).