Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fcntl(2) — HP-UX 5.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

close(2)

exec(2)

open(2)

fcntl(7)

FCNTL(2)

NAME

fcntl − file control

SYNOPSIS

#include <fcntl.h>

int fcntl (fildes, cmd, arg)
int fildes, cmd, arg;

HP-UX COMPATIBILITY

Level: Basic calls: HP-UX/RUN ONLY

Real time extensions: HP-UX/STANDARD − Real Time

Origin: System V, UCB, and HP

DESCRIPTION

Fcntl provides for control over open files.  Fildes is an open file descriptor obtained from a creat, open, dup, fcntl, or pipe system call. 

The cmds available are:

F_DUPFD Return a new file descriptor that has the following characteristics:

Lowest numbered available file descriptor greater than or equal to arg.

Same open file (or pipe) as the original file. 

Same file pointer as the original file (i.e., both file descriptors share one file pointer). 

Same access mode (read, write or read/write). 

Same file status flags (i.e., both file descriptors share the same file status flags). 

The close-on-exec flag associated with the new file descriptor is set to remain open across exec(2) system calls.

F_GETFD Get the close-on-exec flag associated with the file descriptor fildes. If the low-order bit is 0 the file will remain open across exec(2), otherwise the file will be closed upon execution of exec(2).

F_SETFD Set the close-on-exec flag associated with fildes to the low-order bit of arg (see F_GETFD). 

F_GETFL Get file status flags; see fcntl(7).

F_SETFL Set file status flags to arg. Only certain flags can be set; see fcntl(7). 

ERRORS

Fcntl fails if one or more of the following conditions are true.  errno is set accordingly:

­[EBADF] Fildes is not a valid open file descriptor. 

­[EMFILE] Cmd is F_DUPFD and the maximum number of file descriptors is currently open. 

­[EINVAL] Cmd is F_DUPFD and arg is negative or greater than the maximum number of file descriptors. 

RETURN VALUE

Upon successful completion, the value returned depends on cmd as follows:

F_DUPFD A new file descriptor. 

F_GETFD Value of close-on-exec flag (only the low-order bit is defined). 

F_SETFD Value other than −1. 

F_GETFL Value of file status flags. 

F_SETFL Value other than −1. 

Otherwise, a value of −1 is returned and errno is set to indicate the error. 

SEE ALSO

close(2), exec(2), open(2), fcntl(7). 

Hewlett-Packard  —  last mod. May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026