Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / djbunix.h / fd_same.3.md

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

# NAME

fd_same - return whether or not two file descriptors reference the same file

# SYNOPSIS

    #include <limb/djbunix.h>

```pre hl
int fd_same(int <em>fd1</em>, int <em>fd2</em>)
```

# DESCRIPTION

The `fd_same`() function returns whether or not the file descriptors `fd1` and
`fd2` reference the same file.

This is determined by calling [fstat](3) for both and comparing the value of
members `st_dev` and `st_ino` of their respective *struct stat*.

# RETURN VALUE

On success, the `fd_same`() function returns 1 when both file descriptors
reference the same file, and 0 when they don't.
Otherwise, it returns -1 and sets `errno` to indicate the error.

# ERRORS

The `fd_same`() function may fail and set errno for any of the errors specified
for [fstat](3).