2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-05 12:37:56 +00:00

Do not let a missing pid file break the exit callback

The exit callback opened the pid file unguarded, so when it was already gone the
atexit handler raised FileNotFoundError and python reported an exception ignored
in an atexit callback. The removal of the debug socket immediately above is
guarded, so this was an oversight rather than an intent. Verified by stopping
the service with the pid file deleted first.
This commit is contained in:
Markus Hilger
2026-08-13 19:30:06 +02:00
parent 3563da041b
commit 7724a18c43
+9 -4
View File
@@ -230,10 +230,15 @@ def doexit():
os.remove('/var/run/confluent/dbg.sock')
except OSError:
pass
pidfile = open('/var/run/confluent/pid')
pid = pidfile.read()
if pid == str(os.getpid()):
os.remove('/var/run/confluent/pid')
try:
with open('/var/run/confluent/pid') as pidfile:
pid = pidfile.read()
if pid == str(os.getpid()):
os.remove('/var/run/confluent/pid')
except OSError:
# Someone else already tidied it up, which is not worth a traceback out
# of an atexit callback
pass
def _initsecurity(config):