Is relying only on a lock file a good way to tell if a process is running a program?

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











up vote
-1
down vote

favorite












I originally thought that ensuring singleton instance of running a program is based on testing existing of a lock file, or some other way which is entirely dependent on the lock files.



When I read a reply using pid file and also another reply using flock, I found that both ways don't remove the lock files or entirely depend on the lock files. The pid stored in a pdf file is used for matching existing processes, and a flock file doesn't seem to have any difference when a process that creates the flock file is still running and when such a process finishes running.



I also mentioned if we can tell if a process is running a program



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


  • by existence of pid file Does pid file work by assuming pid is not usable?


Thanks.










share|improve this question





















  • unix.stackexchange.com/questions/12815
    – JdeBP
    5 mins ago














up vote
-1
down vote

favorite












I originally thought that ensuring singleton instance of running a program is based on testing existing of a lock file, or some other way which is entirely dependent on the lock files.



When I read a reply using pid file and also another reply using flock, I found that both ways don't remove the lock files or entirely depend on the lock files. The pid stored in a pdf file is used for matching existing processes, and a flock file doesn't seem to have any difference when a process that creates the flock file is still running and when such a process finishes running.



I also mentioned if we can tell if a process is running a program



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


  • by existence of pid file Does pid file work by assuming pid is not usable?


Thanks.










share|improve this question





















  • unix.stackexchange.com/questions/12815
    – JdeBP
    5 mins ago












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I originally thought that ensuring singleton instance of running a program is based on testing existing of a lock file, or some other way which is entirely dependent on the lock files.



When I read a reply using pid file and also another reply using flock, I found that both ways don't remove the lock files or entirely depend on the lock files. The pid stored in a pdf file is used for matching existing processes, and a flock file doesn't seem to have any difference when a process that creates the flock file is still running and when such a process finishes running.



I also mentioned if we can tell if a process is running a program



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


  • by existence of pid file Does pid file work by assuming pid is not usable?


Thanks.










share|improve this question













I originally thought that ensuring singleton instance of running a program is based on testing existing of a lock file, or some other way which is entirely dependent on the lock files.



When I read a reply using pid file and also another reply using flock, I found that both ways don't remove the lock files or entirely depend on the lock files. The pid stored in a pdf file is used for matching existing processes, and a flock file doesn't seem to have any difference when a process that creates the flock file is still running and when such a process finishes running.



I also mentioned if we can tell if a process is running a program



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


  • by existence of pid file Does pid file work by assuming pid is not usable?


Thanks.







lock flock






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 22 mins ago









Tim

24.4k69238426




24.4k69238426











  • unix.stackexchange.com/questions/12815
    – JdeBP
    5 mins ago
















  • unix.stackexchange.com/questions/12815
    – JdeBP
    5 mins ago















unix.stackexchange.com/questions/12815
– JdeBP
5 mins ago




unix.stackexchange.com/questions/12815
– JdeBP
5 mins ago















active

oldest

votes











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%2f478719%2fis-relying-only-on-a-lock-file-a-good-way-to-tell-if-a-process-is-running-a-prog%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478719%2fis-relying-only-on-a-lock-file-a-good-way-to-tell-if-a-process-is-running-a-prog%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)