优化进程管理,添加内部终止方法以避免死锁,调整进程状态更新逻辑,更新测试脚本以延长运行时间

This commit is contained in:
2025-11-04 01:25:53 +08:00
parent fc53b760c3
commit efbc583043
3 changed files with 34 additions and 15 deletions

View File

@@ -83,18 +83,17 @@ std::string create_test_executable() {
std::string exe_path;
#ifdef _WIN32
exe_path = "test_process.exe";
std::ofstream bat_file("test_process.bat");
bat_file << "@echo off\n";
bat_file << "timeout /t 2 /nobreak > nul\n"; // 运行2秒然后退出
bat_file << "exit 0\n";
bat_file.close();
exe_path = "test_process.bat";
std::ofstream bat_file(exe_path);
bat_file << "@echo off\n";
bat_file << "ping 127.0.0.1 -n 6 > nul\n"; // 运行约5秒给监控器足够时间
bat_file << "exit /b 0\n";
bat_file.close();
#else
exe_path = "./test_process.sh";
std::ofstream script_file(exe_path);
script_file << "#!/bin/bash\n";
script_file << "sleep 2\n"; // 运行2秒然后退出
script_file << "sleep 5\n"; // 运行5秒然后退出
script_file << "exit 0\n";
script_file.close();
@@ -113,7 +112,7 @@ std::string create_failing_executable() {
exe_path = "test_fail_process.bat";
std::ofstream bat_file(exe_path);
bat_file << "@echo off\n";
bat_file << "exit 1\n"; // 立即以错误码退出
bat_file << "exit /b 1\n"; // 立即以错误码退出
bat_file.close();
#else
exe_path = "./test_fail_process.sh";