From e278cc1a3a7c5b1c698274cdbb2c583d4f020a5a Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 28 May 2021 00:29:41 -0700 Subject: [PATCH] Exit with non-zero exit code when killed by watchdog (#5732) --- Spigot-Server-Patches/Improved-Watchdog-Support.patch | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Spigot-Server-Patches/Improved-Watchdog-Support.patch b/Spigot-Server-Patches/Improved-Watchdog-Support.patch index d48eee2f48..10804f9c96 100644 --- a/Spigot-Server-Patches/Improved-Watchdog-Support.patch +++ b/Spigot-Server-Patches/Improved-Watchdog-Support.patch @@ -100,6 +100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Spigot end + public volatile Thread shutdownThread; // Paper ++ public volatile boolean abnormalExit = false; // Paper + public static S a(Function function) { AtomicReference atomicreference = new AtomicReference(); @@ -261,10 +262,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 //this.remoteStatusListener.b(); // Paper - don't wait for remote connections } +- System.exit(0); // CraftBukkit + hasFullyShutdown = true; // Paper - System.exit(0); // CraftBukkit ++ System.exit(this.abnormalExit ? 70 : 0); // CraftBukkit // Paper } + @Override @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer @Override public void stop() { @@ -579,6 +582,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + RestartCommand.addShutdownHook( SpigotConfig.restartScript ); + } + // try one last chance to safe shutdown on main incase it 'comes back' ++ server.abnormalExit = true; + server.safeShutdown(false, restart); + try { + Thread.sleep(1000);