2
0
mirror of https://github.com/boostorg/process.git synced 2026-01-19 04:22:15 +00:00

fixed windows interrupt & request_exit test.

This commit is contained in:
Klemens Morgenstern
2023-10-03 03:31:37 +08:00
committed by Klemens Morgenstern
parent f3f8548dea
commit e51970e3bb
3 changed files with 14 additions and 27 deletions

View File

@@ -145,6 +145,7 @@ BOOST_AUTO_TEST_CASE(request_exit)
bpv::process proc(ctx, pth, {"sigterm"}
#if defined(BOOST_PROCESS_V2_WINDOWS)
, bpv::windows::show_window_minimized_not_active
, bpv::windows::create_new_console
#endif
);
BOOST_CHECK(proc.running());
@@ -570,9 +571,10 @@ BOOST_AUTO_TEST_CASE(async_interrupt)
using boost::unit_test::framework::master_test_suite;
const auto pth = bpv::filesystem::absolute(master_test_suite().argv[1]);
bpv::process proc(ctx, pth, {"sigint"}
#if defined(BOOST_PROCESS_V2_WINDOWS)
, bpv::windows::create_new_process_group
, bpv::windows::create_new_process_group
#endif
);
@@ -600,8 +602,9 @@ BOOST_AUTO_TEST_CASE(async_request_exit)
const auto pth = bpv::filesystem::absolute(master_test_suite().argv[1]);
bpv::process proc(ctx, pth, {"sigterm"}
#if defined(ASIO_WINDOWS)
, asio::windows::show_window_minimized_not_active
#if defined(BOOST_PROCESS_V2_WINDOWS)
, bpv::windows::show_window_minimized_not_active
, bpv::windows::create_new_console
#endif
);

View File

@@ -72,12 +72,6 @@ int main(int argc, char * argv[])
GetStartupInfo(&si);
return static_cast<int>(si.wShowWindow);
}
else if (mode == "creation-flags")
{
STARTUPINFO si;
GetStartupInfo(&si);
return static_cast<int>(si.dwFlags);
}
#endif
else if (mode == "sigterm")
{
@@ -86,18 +80,20 @@ int main(int argc, char * argv[])
static boost::asio::steady_timer * tim_p = &tim;
#if defined(BOOST_PROCESS_V2_WINDOWS)
BOOST_ASSERT(SetConsoleCtrlHandler(
SetConsoleCtrlHandler(
[](DWORD kind)
{
if (kind == CTRL_CLOSE_EVENT)
{
// windows doesn't like us doing antyhing else
::exit(0);
if (tim_p != nullptr)
tim_p->cancel();
return TRUE;
}
else
return FALSE;
}, TRUE) != 0);
}, TRUE);
#else
signal(SIGTERM, [](int) { if (tim_p != nullptr) tim_p->cancel();});
#endif
@@ -115,8 +111,8 @@ int main(int argc, char * argv[])
static boost::asio::steady_timer * tim_p = &tim;
#if defined(BOOST_PROCESS_V2_WINDOWS)
BOOST_ASSERT(
SetConsoleCtrlHandler(
SetConsoleCtrlHandler(NULL, FALSE);
auto res = SetConsoleCtrlHandler(
[](DWORD kind)
{
if (kind == CTRL_C_EVENT)
@@ -127,7 +123,8 @@ int main(int argc, char * argv[])
}
else
return FALSE;
}, TRUE) != 0);
}, TRUE);
BOOST_ASSERT(res != FALSE);
#else
signal(SIGINT, [](int) { if (tim_p != nullptr) tim_p->cancel();});
#endif

View File

@@ -50,19 +50,6 @@ BOOST_AUTO_TEST_CASE(show_window)
}
BOOST_AUTO_TEST_CASE(creation_flags)
{
using boost::unit_test::framework::master_test_suite;
const auto pth = master_test_suite().argv[1];
asio::io_context ctx;
bpv::process proc{ctx, pth, {"creation-flags"}};
BOOST_CHECK_EQUAL(proc.wait() & ~EXTENDED_STARTUPINFO_PRESENT, 0);
proc = bpv::process{ctx, master_test_suite().argv[1], {"creation-flags"}, bpv::windows::process_creation_flags<STARTF_TITLEISAPPID>()};
BOOST_CHECK(proc.running());
BOOST_CHECK_EQUAL(proc.wait() & ~EXTENDED_STARTUPINFO_PRESENT, STARTF_TITLEISAPPID);
}
BOOST_AUTO_TEST_CASE(as_user_launcher)
{