01.01.2013 Views

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

FCNTL (2) FCNTL (2)<br />

NAME<br />

fcntl - file control<br />

SYNOPSIS<br />

#include <br />

int fcntl (fildes, cmd, arg)<br />

int fildes, cmd, arg;<br />

DESCRIPTION<br />

Fcntl provides for control over open files. Fildes is an open file<br />

descriptor obtained from a creat , open, dup, fcntl, or pipe system<br />

call.<br />

The cmds available are:<br />

F_DUPFD<br />

F_GETFD<br />

F_SETFD<br />

F_GETFL<br />

F_SETFL<br />

F_GETLK<br />

F_SETLK<br />

Return a new file descriptor as follows:<br />

Lowest numbered available file descriptor greater<br />

than or equal to arg .<br />

Same open file (or pipe) as the original file.<br />

Same file pointer as the original file (i.e., both file<br />

descriptors share one file pointer).<br />

Same access mode (read, write or read/write).<br />

Same file status flags (i.e., both file descriptors share<br />

the same file status flags).<br />

The close-on-exec flag associated with the new file<br />

descriptor is set to remain open across exec(2) system<br />

calls.<br />

Get the close-on-exec flag associated with the file<br />

descriptor fildes . If the low-order bit is 0 the file<br />

will remain open across exec, otherwise the file will<br />

be closed upon execution of exec .<br />

Set the close-on-exec flag associated with fildes to<br />

the low-order bit of arg (0 or 1 as above).<br />

Get file status flags.<br />

Set file status flags to arg . Only certain flags can<br />

be set; see fcntl(5).<br />

Get the first block which blocks the lock description<br />

given by the variable of type struct flock pointed to<br />

by arg . The information retrieved overwrites the<br />

information passed to fcntl in the flock structure. If<br />

no lock is found that would prevent this lock from<br />

being created, then the structure is passed back<br />

unchanged except for the lock type which will be set<br />

to F_UNLCK.<br />

Set or clear a file segment lock according to the variable<br />

of type struct flock pointed to by arg [see<br />

fcntl(5)] . The cmd F _SETLK is used to establish<br />

read (F _RDLCK) and write (F _ WRLCK) locks, as<br />

well as remove either type of lock (F _UNLCK). If a<br />

read or write lock cannot be set fcntl will return<br />

- 1-

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!