As you noted Linux, verbatim form man lockf (highlighted by me):
On Linux, lockf () is just an interface on top of fcntl (2) locks. Many other systems implement lockf () this way, but note that POSIX.1-2001 leaves the connection between lockf () and fcntl (2) unspecified locks. Perhaps the portable application should avoid mixing calls with these interfaces.
So, looking through the current glibc sources ( eglibc-2.11.3/io/lockf.c ), a possible use of fcntl() to implement locking is as follows:
In order to first perform this compilation, you need several mods:
- replace
__fcntl with fcntl - replace
__set_errno(<errno-define>) with errno = <errno-define>
.. and secondly so that it becomes async-signal-save:
- replace the call with
memset() with the appropriate settings for the struct fcntl variable.
source share