Can we tell if a command is being run by a process or not, by looking at the flock lock file alone?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












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


Thanks.









share



























    up vote
    0
    down vote

    favorite












    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


    Thanks.









    share

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      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


      Thanks.









      share















      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


      Thanks.







      lock flock





      share














      share












      share



      share








      edited 19 secs ago

























      asked 9 mins ago









      Tim

      24.4k69238426




      24.4k69238426




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          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.





          share




















          • Thanks. How about the rest of my questions?
            – Tim
            53 secs ago










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478712%2fcan-we-tell-if-a-command-is-being-run-by-a-process-or-not-by-looking-at-the-flo%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          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.





          share




















          • Thanks. How about the rest of my questions?
            – Tim
            53 secs ago














          up vote
          1
          down vote













          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.





          share




















          • Thanks. How about the rest of my questions?
            – Tim
            53 secs ago












          up vote
          1
          down vote










          up vote
          1
          down vote









          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.





          share












          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.






          share











          share


          share










          answered 2 mins ago









          sebasth

          7,70331745




          7,70331745











          • Thanks. How about the rest of my questions?
            – Tim
            53 secs ago
















          • Thanks. How about the rest of my questions?
            – Tim
            53 secs ago















          Thanks. How about the rest of my questions?
          – Tim
          53 secs ago




          Thanks. How about the rest of my questions?
          – Tim
          53 secs ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478712%2fcan-we-tell-if-a-command-is-being-run-by-a-process-or-not-by-looking-at-the-flo%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)