PEX(3)

NAME
pex, unpex - obtain process-exclusive file access

SYNOPSIS
#include <sys/pex.h>

int pex(fd, seconds, pexbuf)
struct pexclude *pexbuf;

int unpex(fd, seconds)

DESCRIPTION
Pex tries, using the ioctl call, to obtain exclusive access to the file designated by file descriptor fd; see pex(4). If pexbuf is nonzero, facts about the other end of the pipe are placed in the object pexbuf points to, as described in pex(4).

If fd refers to a stream, pex first empties the input and output queues, flushing if seconds is negative, and otherwise waiting up to the specified time interval for the queues to drain. If the queues do not drain, an error results.

Unpex uses to try to reverse the effect of pex, again flushing or draining queues as specified by seconds.

On a pipe, pex or unpex succeeds only if the process at the other end answers with an FIOPX or FIONPX ioctl respectively. Pex and unpex should not be used to answer.

SEE ALSO
pex(4)

DIAGNOSTICS
Pex returns -1 on failure, 0 on success, and 1 for a half-pexed pipe.