From a731a20673e0da05b88cc17eaad781f3c217712a Mon Sep 17 00:00:00 2001 From: Andreas Hoechner Date: Fri, 13 Sep 2024 17:15:40 +0200 Subject: [PATCH] [seiscomp-control] Remove fun- and pid-file upon seiscomp stop --- src/system/apps/seiscomp/seiscomp-control.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/system/apps/seiscomp/seiscomp-control.py b/src/system/apps/seiscomp/seiscomp-control.py index c1b270d..cbc1102 100644 --- a/src/system/apps/seiscomp/seiscomp-control.py +++ b/src/system/apps/seiscomp/seiscomp-control.py @@ -248,6 +248,7 @@ def start_module(mod): def stop_module(mod): + returncode = 0 try: r = mod.stop() if r is None: @@ -256,26 +257,31 @@ def stop_module(mod): elif type(r) == type(True): # Boolean type: True = success, False = error if not r: - return 1 + returncode = 1 elif type(r) == type(0): # Integer type: 0 = success, error otherwise if r: - return 1 + returncode = 1 else: # Any other type: Truthy = success, Falsy = error if not r: - return 1 + returncode = 1 except Exception as e: error(f"Failed to stop {mod.name}: {str(e)}") return 1 - # Delete runfile + # Delete runfile and pidfile try: - os.remove(env.runFile(mod.name)) + runFile = env.runFile(mod.name) + if os.path.isfile(runFile): + os.remove(runFile) + pidFile = f"{runFile.split('.')[0]}.pid" + if os.path.isfile(pidFile): + os.remove(pidFile) except BaseException: - return 1 + returncode = 1 - return 0 + return returncode def start_kernel_modules():