#2353: 优化游戏进程被 SIGKILL 信号终止时的提示 (#2358)

Co-authored-by: Yuhui Huang <jackhuang1998@gmail.com>
This commit is contained in:
Glavo 2023-07-10 15:06:28 +08:00 committed by GitHub
parent bbe0f5d750
commit f29e350b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 2 deletions

View File

@ -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);

View File

@ -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

View File

@ -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 版本

View File

@ -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 版本

View File

@ -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;
}

View File

@ -51,6 +51,7 @@ public interface ProcessListener {
enum ExitType {
JVM_ERROR,
APPLICATION_ERROR,
SIGKILL,
NORMAL,
INTERRUPTED
}