This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch aevri/win32_minimal in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit cdae0ea7d17a713d914154b3bc6f7c4d1046a8e1 Author: Angelos Evripiotis <[email protected]> AuthorDate: Fri Oct 4 18:07:53 2019 +0100 _platform: add does_support_signals() accessor We'll need this information for doing the right thing with signals on Windows. --- src/buildstream/_platform/platform.py | 12 ++++++++++++ src/buildstream/_platform/win32.py | 30 +++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py index af49b9e..b364ef8 100644 --- a/src/buildstream/_platform/platform.py +++ b/src/buildstream/_platform/platform.py @@ -190,6 +190,18 @@ class Platform(): # set to the platform default by `get_start_method`. return multiprocessing.get_start_method() != 'fork' + # does_support_signals(): + # + # Returns True if the platform has good support for signals, this will not + # be true for Windows. + # + # Returns: + # (bool): Whether signals are supported or not + # + def does_support_signals(self): + # Most platforms support signals, so the default is True. + return True + ################################################################## # Sandbox functions # ################################################################## diff --git a/src/buildstream/_platform/win32.py b/src/buildstream/_platform/win32.py index bb763cd..128f1ed 100644 --- a/src/buildstream/_platform/win32.py +++ b/src/buildstream/_platform/win32.py @@ -53,4 +53,32 @@ class Win32(Platform): def _setup_dummy_sandbox(self): self.check_sandbox_config = Win32._check_dummy_sandbox_config self.create_sandbox = Win32._create_dummy_sandbox - return True \ No newline at end of file + return True + + def does_support_signals(self): + # Windows does not have good support for signals, and we shouldn't + # handle them in the same way we do on UNIX. + # + # From the MSDN docs: + # + # > SIGINT is not supported for any Win32 application. When a CTRL+C + # > interrupt occurs, Win32 operating systems generate a new thread to + # > specifically handle that interrupt. This can cause a single-thread + # > application, such as one in UNIX, to become multithreaded and cause + # > unexpected behavior. + # + # > The SIGILL and SIGTERM signals are not generated under Windows. + # > They are included for ANSI compatibility. Therefore, you can set + # > signal handlers for these signals by using signal, and you can also + # > explicitly generate these signals by calling raise. + # + # The only other signals that are defined in signal.h on Windows are + # not relevant to us: + # + # - SIGABRT + # - SIGFPE + # - SIGSEGV + # + # https://docs.microsoft.com/en-gb/cpp/c-runtime-library/reference/signal + # + return False
