# HG changeset patch # User Kim Alvefur # Date 1711564391 -3600 # Node ID c2a476f4712a8fe1dff9320d6a7ef4ad4842e5f4 # Parent 5d9ec2e55d74113d5e38ee6ad0262e75d08faf1d util.startup: Fix exiting on pidfile trouble prosody.shutdown() relies on prosody.main_thread, which has not been set yet at this point. Doing a clean shutdown might actually be harmful in case it tears down things set up by the conflicting Prosody, such as the very pidfile we were looking at. Thanks again SigmaTel71 for noticing diff -r 5d9ec2e55d74 -r c2a476f4712a util/startup.lua --- a/util/startup.lua Wed Mar 27 15:39:03 2024 +0000 +++ b/util/startup.lua Wed Mar 27 19:33:11 2024 +0100 @@ -719,20 +719,20 @@ local pidfile_handle, err = io.open(pidfile, mode); if not pidfile_handle then log("error", "Couldn't write pidfile at %s; %s", pidfile, err); - prosody.shutdown("Couldn't write pidfile", 1); + os.exit(1); else prosody.pidfile = pidfile; if not lfs.lock(pidfile_handle, "w") then -- Exclusive lock local other_pid = pidfile_handle:read("*a"); log("error", "Another Prosody instance seems to be running with PID %s, quitting", other_pid); prosody.pidfile_handle = nil; - prosody.shutdown("Prosody already running", 1); + os.exit(1); else pidfile_handle:close(); pidfile_handle, err = io.open(pidfile, "w+"); if not pidfile_handle then log("error", "Couldn't write pidfile at %s; %s", pidfile, err); - prosody.shutdown("Couldn't write pidfile", 1); + os.exit(1); else if lfs.lock(pidfile_handle, "w") then pidfile_handle:write(tostring(pposix.getpid()));