aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2018-10-16 00:35:47 -0700
committerRobert Schumacher <roschuma@microsoft.com>2018-10-16 00:35:47 -0700
commit56e1d2f6961693b45f2b61b6e6985229be56e674 (patch)
tree2aded58aa0c6db7e09496d07acff62f5ec29e380 /toolsrc/include
parent5d0b56d7c1b30709a4fc6c7899ef01781ee155e6 (diff)
downloadvcpkg-56e1d2f6961693b45f2b61b6e6985229be56e674.tar.gz
vcpkg-56e1d2f6961693b45f2b61b6e6985229be56e674.zip
[vcpkg] Wrap all external process spawning in a Ctrl-C catcher to avoid corrupted consoles
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/base/system.h8
-rw-r--r--toolsrc/include/vcpkg/globalstate.h20
2 files changed, 24 insertions, 4 deletions
diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h
index 3c4326ade..005e09a3f 100644
--- a/toolsrc/include/vcpkg/base/system.h
+++ b/toolsrc/include/vcpkg/base/system.h
@@ -32,15 +32,15 @@ namespace vcpkg::System
};
int cmd_execute_clean(const CStringView cmd_line,
- const std::unordered_map<std::string, std::string>& extra_env = {});
+ const std::unordered_map<std::string, std::string>& extra_env = {}) noexcept;
- int cmd_execute(const CStringView cmd_line);
+ int cmd_execute(const CStringView cmd_line) noexcept;
#if defined(_WIN32)
- void cmd_execute_no_wait(const CStringView cmd_line);
+ void cmd_execute_no_wait(const CStringView cmd_line) noexcept;
#endif
- ExitCodeAndOutput cmd_execute_and_capture_output(const CStringView cmd_line);
+ ExitCodeAndOutput cmd_execute_and_capture_output(const CStringView cmd_line) noexcept;
enum class Color
{
diff --git a/toolsrc/include/vcpkg/globalstate.h b/toolsrc/include/vcpkg/globalstate.h
index bc28e3ff8..2a76c8741 100644
--- a/toolsrc/include/vcpkg/globalstate.h
+++ b/toolsrc/include/vcpkg/globalstate.h
@@ -18,5 +18,25 @@ namespace vcpkg
static std::atomic<int> g_init_console_cp;
static std::atomic<int> g_init_console_output_cp;
+ static std::atomic<bool> g_init_console_initialized;
+
+ struct CtrlCStateMachine
+ {
+ void transition_to_spawn_process() noexcept;
+ void transition_from_spawn_process() noexcept;
+ void transition_handle_ctrl_c() noexcept;
+
+ private:
+ enum class CtrlCState
+ {
+ normal,
+ blocked_on_child,
+ exit_requested,
+ };
+
+ std::atomic<CtrlCState> m_state = CtrlCState::normal;
+ };
+
+ static CtrlCStateMachine g_ctrl_c_state;
};
}