I have a C++ program that locks files using POSIX advisory locks. That is, it uses the POSIX fcntl system call for lock operations. I want a Java program to interoperate wit
Try this:
(1) Write a small java program that locks a file and sleeps (or otherwise stops executing).
(2) cat /proc/locks
(3) You'll see lines like the following:
24: POSIX ADVISORY READ 1784 08:01:27384070 1073742826 1073742335
25: FLOCK ADVISORY WRITE 815 00:0f:9772 0 EOF
Identify your process ID from column 5. If column 2 is FLOCK then flock
is being used. If it is POSIX then column 2 will be POSIX, indicating fcntl (or lockf
which is build on top of fcntl
) is being used.
If java has to choose one or the other then POSIX would be the sensible choice as it supports record locking.