#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
6 changed files with 14 additions and 2 deletions

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
}