Is there a standard Linux library for "lock files"? -


suppose have folder , want 1 instance of application working on @ time. can synchronize via filesystem itself. times accomplished .lock_file if that's present know instance using it. there standard libraries handle sort of thing?

if using c/c++, see fclnt or flock : locking files in linux c/c++

if using java, see filechannel lock method , how can lock file using java (if possible)

you can check existence of .lock_file opening open(pathname, o_creat | o_excl, 0644), see open man page, creates , opens file , returns eexist if pathname exists.

in java, calling file method createnewfile() can use create atomically .lock_file


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -