diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/GameCrashWindow.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/GameCrashWindow.java index dcfc45bac..2e2f8b556 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/GameCrashWindow.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/GameCrashWindow.java @@ -290,6 +290,9 @@ public class GameCrashWindow extends Stage { case APPLICATION_ERROR: title.setText(i18n("launch.failed.exited_abnormally")); break; + case SIGKILL: + title.setText(i18n("launch.failed.sigkill")); + break; } titlePane.setAlignment(Pos.CENTER); diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 0531a3f62..2aad62adb 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -678,6 +678,7 @@ launch.failed.execution_policy.hint=The current execution policy prevents the ex Click on 'OK' to allow the current user to execute PowerShell scripts, or click on 'Cancel' to keep it as it is. launch.failed.exited_abnormally=Game crashed. Please refer to the crash log for more details. launch.failed.no_accepted_java=Unable to find a compatible Java version, do you want to start the game with the default Java?\nClick on 'Yes' to start the game with the default Java.\nOr, you can go to the instance settings to select one yourself. +launch.failed.sigkill=Game was forcibly terminated by the user or system. launch.state.dependencies=Resolving dependencies launch.state.done=Completing launch launch.state.java=Checking Java version diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 0666182cb..17c716366 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -554,6 +554,7 @@ launch.failed.execution_policy.failed_to_set=設定執行策略失敗 launch.failed.execution_policy.hint=當前執行策略封锁您執行 PowerShell 腳本。\n點擊“確定”允許當前用戶執行本地 PowerShell 腳本,或點擊“取消”保持現狀。 launch.failed.exited_abnormally=遊戲非正常退出,請查看記錄檔案,或聯絡他人尋求幫助。 launch.failed.no_accepted_java=找不到適合當前遊戲使用的 Java,是否使用默認 Java 啟動遊戲?點擊“是”使用默認 Java 繼續啟動遊戲,\n或者請到遊戲設定中選擇一個合適的Java虛擬機器版本。 +launch.failed.sigkill=遊戲被用戶或系統強制終止。 launch.state.dependencies=處理遊戲相依元件 launch.state.done=啟動完成 launch.state.java=檢測 Java 版本 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index d38ca1692..5d7cb2ae8 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -554,6 +554,7 @@ launch.failed.execution_policy.failed_to_set=设置执行策略失败 launch.failed.execution_policy.hint=当前执行策略阻止您执行 PowerShell 脚本。\n点击“确定”允许当前用户执行本地 PowerShell 脚本,或点击“取消”保持现状。 launch.failed.exited_abnormally=游戏非正常退出,请查看日志文件,或联系他人寻求帮助。 launch.failed.no_accepted_java=找不到适合当前游戏使用的 Java,是否使用默认 Java 启动游戏?点击“是”使用默认 Java 继续启动游戏,\n或者请到全局(特定)游戏设置中选择一个合适的 Java 虚拟机版本。\n你可以点击右上角帮助按钮进行求助。 +launch.failed.sigkill=游戏被用户或系统强制终止。 launch.state.dependencies=处理游戏依赖 launch.state.done=启动完成 launch.state.java=检测 Java 版本 diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/ExitWaiter.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/ExitWaiter.java index 5c7e262e5..2d355c4c0 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/ExitWaiter.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/ExitWaiter.java @@ -24,13 +24,13 @@ import org.jackhuang.hmcl.event.ProcessStoppedEvent; import org.jackhuang.hmcl.util.Log4jLevel; import org.jackhuang.hmcl.util.StringUtils; import org.jackhuang.hmcl.util.platform.ManagedProcess; +import org.jackhuang.hmcl.util.platform.OperatingSystem; import java.util.Collection; import java.util.List; import java.util.function.BiConsumer; /** - * * @author huangyuhui */ final class ExitWaiter implements Runnable { @@ -71,7 +71,12 @@ final class ExitWaiter implements Runnable { exitType = ProcessListener.ExitType.JVM_ERROR; } else if (exitCode != 0 || StringUtils.containsOne(errorLines, "Unable to launch")) { EventBus.EVENT_BUS.fireEvent(new ProcessExitedAbnormallyEvent(this, process)); - exitType = ProcessListener.ExitType.APPLICATION_ERROR; + + if (exitCode == 137 && OperatingSystem.CURRENT_OS == OperatingSystem.LINUX) { + exitType = ProcessListener.ExitType.SIGKILL; + } else { + exitType = ProcessListener.ExitType.APPLICATION_ERROR; + } } else { exitType = ProcessListener.ExitType.NORMAL; } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/ProcessListener.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/ProcessListener.java index 2b3605fa7..523b9cf93 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/ProcessListener.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/ProcessListener.java @@ -51,6 +51,7 @@ public interface ProcessListener { enum ExitType { JVM_ERROR, APPLICATION_ERROR, + SIGKILL, NORMAL, INTERRUPTED }