According to @alk, answer in the subject :
We can develop our flock() function (its name may be async_flock() ). in this new function, we copy the contents of the lockf() source code and then make the following changes to get a safe asynchronous function:
- replace
__fcntl with fcntl : code must be compiled replace __set_errno(<errno-define>) with errno = <errno-define> : you need to compile the code
replace the call with memset() with the appropriate settings struct fcntl = {0} : it needs to become async-signal persistence.
source share