flopen(3bsd)
π flopen(3bsd) π
okay bestie, welcome to the flopen page from section 3bsd of the local manual β yes it's literally called flopen(3bsd), that's the whole name, we're not being weird about it β¨
πΈ NAME πΈ
flopen, flopenat β Reliably open and lock a file
no fr, that's the whole vibe: open it AND lock it, no cap π
π LIBRARY π
Utility functions from BSD systems (libbsd, -lbsd)
β¨ SYNOPSIS β¨
#include <sys/fcntl.h>
#include <libutil.h>
(See libbsd(7) for include usage.)
int
flopen(const char *path, int flags);
int
flopen(const char *path, int flags, mode_t mode);
int
flopenat(int fd, const char *path, int flags);
int
flopenat(int fd, const char *path, int flags, mode_t mode);
π¦ DESCRIPTION π¦
so the flopen() function opens or creates a file and acquires an exclusive lock on it π
it is essentially equivalent with calling open() with the same parameters followed by flock() with an operation argument of LOCK_EX, except that flopen() will attempt to detect and handle races that may occur between opening / creating the file and locking it π«Ά
the way that makes it chef's kiss for opening lock files, PID files, spool files, mailboxes and other kinds of files which are used for synchronization between processes β it's giving main character energy for process coordination fr fr π
If flags includes O_NONBLOCK and the file is already locked, flopen() will fail and set errno to EWOULDBLOCK π (no waiting around for you, bestie, it's busy)
As with open(), the additional mode argument is required if flags includes O_CREAT β οΈ
The flopenat() function is equivalent to the flopen() function except in the case where the path specifies a relative path. In this case the file to be opened is determined relative to the directory associated with the file descriptor fd instead of the current working directory π
If flopenat() is passed the special value AT_FDCWD in the fd parameter, the current working directory is used and the behavior is identical to a call to flopen() β¨
π RETURN VALUES π
If successful, flopen() returns a valid file descriptor π Otherwise, it returns -1, and sets errno as described in flock(2) and open(2) π
π SEE ALSO π
π AUTHORS π
The flopen function and this manual page were written by Dag-Erling SmΓΈrgrav <des@FreeBSD.org> π absolute icon, we love to see it
and that's the page, bestie!! this cutie came to you from Debian, dated July 28, 2017, and it lives in the flopen(3bsd) manual π go lock some files responsibly, mwah πβ¨
π¦ where this page comes from
- alpine 3.22: libbsd-doc 0.12.2-r0 Β· BSD-3-Clause
- alpine 3.23: libbsd-doc 0.12.2-r0 Β· BSD-3-Clause
- alpine 3.24: libbsd-doc 0.12.2-r0 Β· BSD-3-Clause
- arch rolling: libbsd 0.12.2-2 Β· custom
- debian bookworm: libbsd-dev 0.11.7-2
- debian trixie: libbsd-dev 0.12.2-2
- epel 10: libbsd-devel 0.12.2-4.el10_0 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- epel 9: libbsd-devel 0.12.2-1.el9 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 43: libbsd-devel 0.12.2-6.fc43 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 43: libbsd-devel 0.12.2-6.fc43 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 44: libbsd-devel 0.12.2-7.fc44 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 44: libbsd-devel 0.12.2-7.fc44 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- nixos 26.05: libbsd 0.12.2
- nixpkgs unstable: libbsd 0.12.2
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- ubuntu noble: libbsd-dev 0.12.1-1build1
- ubuntu noble: libbsd-dev 0.12.1-1build1.1
- ubuntu questing: libbsd-dev 0.12.2-2build1
- ubuntu resolute: libbsd-dev 0.12.2-2build2
- ubuntu stonking: libbsd-dev 0.12.2-3
- Copyright (c) 2007 Dag-Erling CoΓ―dan SmΓΈrgrav
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms