Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

flopen(3) [debian man page]

FLOPEN(3)						   BSD Library Functions Manual 						 FLOPEN(3)

NAME
flopen -- reliably open and lock a file LIBRARY
Utility functions from BSD systems (libbsd, -lbsd) SYNOPSIS
#include <sys/fcntl.h> #include <bsd/libutil.h> int flopen(const char *path, int flags); int flopen(const char *path, int flags, mode_t mode); DESCRIPTION
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. Thus, it is well suited for opening lock files, PID files, spool files, mailboxes and other kinds of files which are used for synchronization between processes. If flags includes O_NONBLOCK and the file is already locked, flopen() will fail and set errno to EWOULDBLOCK. As with open(), the additional mode argument is required if flags includes O_CREAT. 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
errno(2), flock(2), open(2) AUTHORS
The flopen function and this manual page were written by Dag-Erling Smorgrav <des@FreeBSD.org>. BSD
June 6, 2009 BSD

Check Out this Related Man Page

FLOPEN(3)						   BSD Library Functions Manual 						 FLOPEN(3)

NAME
flopen -- Reliably open and lock a file LIBRARY
System Utilities Library (libutil, -lutil) SYNOPSIS
#include <sys/fcntl.h> #include <libutil.h> int flopen(const char *path, int flags); int flopen(const char *path, int flags, mode_t mode); DESCRIPTION
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. Thus, it is well suited for opening lock files, PID files, spool files, mailboxes and other kinds of files which are used for synchronization between processes. If flags includes O_NONBLOCK and the file is already locked, flopen() will fail and set errno to EWOULDBLOCK. As with open(), the additional mode argument is required if flags includes O_CREAT. 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
errno(2), flock(2), open(2) AUTHORS
The flopen function and this manual page were written by Dag-Erling Smorgrav <des@FreeBSD.org>. BSD
June 6, 2009 BSD
Man Page

4 More Discussions You Might Find Interesting

1. Programming

files

if i am opening a file in one process how can i cause that other process can't open thae same file??? (3 Replies)
Discussion started by: dbargo
3 Replies

2. Shell Programming and Scripting

open files

I want to open a file and edit it using vi However, i dont want to open directories or binary files. how can i do this? Right now it opens all files without caring echo "please enter a file to edit in Vi" read file if then (2 Replies)
Discussion started by: icelated
2 Replies

3. Shell Programming and Scripting

too many open files

HI I am trying to run the following script for 317 files (*.m) and I get this error : awk: xfile.m makes too many open files what's the solution pls ? $ cat ocstr2.awk # If the code contains @"LBL_....", replace it with C_LBL_... and # remember the labels for later. match($0,... (3 Replies)
Discussion started by: molwiko
3 Replies

4. Programming

Function open() sets errno

I am opening a text file using open() system call in O_RDONLY mode. open() returns me a valid handler but also sets errno to 13 i.e. EACCES(Permission denied). Question is when open() is returning a valid handler then why does it sets the errno? Should not errno be set only in case of error... (10 Replies)
Discussion started by: rupeshkp728
10 Replies