Is util-linux's flock implemented based on flock() in Linux C API?

Can we tell if a command is being run by a process or not, by looking at the lock file alone? I found that when a command guarded by flock finishes running, there seems no change to the lock file. Here is when it is running and after it finishes running:

$ ls -l ../sleep.flock.file 
-rw-rw-r-- 1 t t 0 Oct 30 14:01 ../sleep.flock.file
$ ls -l ../sleep.flock.file 
-rw-rw-r-- 1 t t 0 Oct 30 14:01 ../sleep.flock.file



Yes. It is explicitly stated in man 1 flock that flock command uses flock() and man 2 flock notes section says that flock() is implemented by system call since Linux kernel 2.0.

  • Thanks. How about the rest of my questions? – Tim Oct 30 '18 at 18:18
  • 1
    @Tim You should ask a single question per post... See the help and docs for U&L it will tell you so. – filbranden Oct 30 '18 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.