Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

System Functions (f - i) fcntl(2)
Changing or unlocking a portion from the middle of a larger locked segment leaves a smaller
segment at either end. Locking a segment that is already locked by the calling process causes the
old lock type to be removed and the new lock type to take effect. All locks associated with a file
for a given process are removed when a file descriptor for that file is closed by that process or
when the process holding that file descriptor terminates. Locks are not inherited by a child pro-
cess in a function like fork( ), tdm_fork( ),ortdm_spawn( ).
NOTES
To use the fcntl( ) functionality in a threaded application that uses the Standard POSIX Threads
library, see spt_fcntlz(2).
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running H06.21 or later RVUs or J06.10 or later RVUs, you must perform all of the fol-
lowing tasks to make the function thread-aware in a multi-threaded application:
Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
Link the application to the zputdll library (/G/system/zdllnnn/zputdll).
On systems running H06.24 or later H-series RVUs or J06.13 or later J-series RVUs, you can use
this function with 32-bit or 64-bit OSS applications.
To use this function in a 32-bit threaded application on systems running H06.24 or later RVUs or
J06.13 or later RVUs, perform the same tasks (described above) used to make the function
thread-aware in a multi-threaded application on systems running H06.21/J06.10 or later RVUs.
To use this function in a 64-bit threaded application on systems running H06.24 or later RVUs or
J06.13 or later RVUs, you must perform all of the following tasks to make the function thread-
aware in a multi-threaded application:
Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
Compile the application using the -Wlp64 compiler command option.
Link the application to the yputdll library (/G/system/zdllnnn/yputdll).
For detailed information about writing multi-threaded and 64-bit applications for the Open Sys-
tem Services environment, see the Open System Services Programmer’s Guide.
RETURN VALUES
Upon successful completion, the value returned by the fcntl( ) function depends on the value of
the request parameter, listed:
F_DUPFD Returns a new file descriptor.
F_GETFD Returns the value of the file descriptor flags. The return value is not negative.
F_GETFL Returns the value of file status flags and access modes. The return value is not
negative.
F_GETLK Returns the value 0 (zero).
F_GETLK64 Returns the value 0 (zero).
F_GETOWN Returns the process ID or process group ID of the socket receiving a SIGURG
signal. A positive value is a process ID; a negative value is a process group ID.
F_SETFD Returns the value 0 (zero).
527186-023 Hewlett-Packard Company 315