You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:09:06 UTC

[buildstream] 03/16: _platform: add does_support_signals() accessor

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch aevri/win32_receive_signals
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit ca9dd39eb5d62bcf86fc811332c974d348531039
Author: Angelos Evripiotis <je...@bloomberg.net>
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    | 28 ++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

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 3668001..8dc2d8e 100644
--- a/src/buildstream/_platform/win32.py
+++ b/src/buildstream/_platform/win32.py
@@ -57,3 +57,31 @@ class Win32(Platform):
         self.check_sandbox_config = Win32._check_dummy_sandbox_config
         self.create_sandbox = Win32._create_dummy_sandbox
         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