sopenfd()

Open for shared access a file associated with a given descriptor

Synopsis:

#include <unistd.h>

int sopenfd( int fd,
             int oflag,
             int sflag );

Arguments:

fd
A file descriptor associated with the file that you want to open.
oflag
How you want to open the file; a combination of the following bits:
sflag
How you want the file to be shared; a combination of the following bits:

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The sopenfd() function opens for shared access the file associated with the file descriptor, fd. The access mode, oflag, must be equal to or more restrictive than the access mode of the source fd.

Note that:

openfd( fd, oflag );

is the same as:

sopenfd( fd, oflag, SH_DENYNO );

Returns:

The file descriptor, or -1 if an error occurs (errno is set).

Errors:

EBADF
Invalid file descriptor fd.
EACCES
The access mode specified by oflag isn't equal to or more restrictive than the access mode of the source fd.
EBUSY
Sharing mode (sflag) was denied due to a conflicting open.

Classification:

Unix

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

openfd()