Understand pid-files and flock in context of BIT

Good morning folks, I discovered "common/application_instance.py" and the class in it. I was wondering what it does. In my current state of investigation I would describe it as a "PID file and flock manager". I've never used PID files or flock in my own projects but I do understand the basics. I also found a good explanation [1] why PID and flock is used in combination. My problem is to understand that technology in the context of Back In Time. In which situation does Back In Time need it. Maybe someone else understand that better? Maybe I will dive deeper into the code and document my findings in the modules docstring. I want to understand in which situations PID and flock is used by BIT and why. Kind Christian [1] -- <https://unix.stackexchange.com/a/12816/136851>

Please let me add something concrete here. In "common/applicationinstance.py" beginning with line 53 "ApplicationInstance.check()" def check(self, autoExit = False): """ Check if the current application is already running ... Returns: bool: ``True`` if this is the only application instance """ #check if the pidfile exists if not os.path.isfile(self.pidFile): return True The "if" here confuses me. When the pidfile do NOT exists the "application" is running and is the "only instance"? Shouldn't it be the opposite? When the pidfile isthere (and has the process own PID as content) then the application is running and True should be returned. I don't think I've found a bug here. I assume I totally misunderstand something about the usage of pidfiles. Kind Christian

The docstring explains it :) On 27.09.2022 17:06, c.buhtz@posteo.jp wrote:
The key words are: "THIS is the ONLY application instance", meaning: the process that is currently running is ALONE, because there is NO OTHER backintime instance running. This is True if there is NO pidfile from any other instance :) Michael

Please let me add something concrete here. In "common/applicationinstance.py" beginning with line 53 "ApplicationInstance.check()" def check(self, autoExit = False): """ Check if the current application is already running ... Returns: bool: ``True`` if this is the only application instance """ #check if the pidfile exists if not os.path.isfile(self.pidFile): return True The "if" here confuses me. When the pidfile do NOT exists the "application" is running and is the "only instance"? Shouldn't it be the opposite? When the pidfile isthere (and has the process own PID as content) then the application is running and True should be returned. I don't think I've found a bug here. I assume I totally misunderstand something about the usage of pidfiles. Kind Christian

The docstring explains it :) On 27.09.2022 17:06, c.buhtz@posteo.jp wrote:
The key words are: "THIS is the ONLY application instance", meaning: the process that is currently running is ALONE, because there is NO OTHER backintime instance running. This is True if there is NO pidfile from any other instance :) Michael
participants (2)
-
c.buhtz@posteo.jp
-
Michael Büker