summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpxinwr <peixing.xin@windriver.com>2020-11-30 21:48:33 (GMT)
committerGitHub <noreply@github.com>2020-11-30 21:48:33 (GMT)
commit1244c816d7cdfa8a26d1671cab67122a8c5271a7 (patch)
tree256d01f36bfef2b7f7b5235069ebaf275f692aba
parent5c73afc36ee6cca41009a510092e1f901c5dc0a0 (diff)
downloadcpython-1244c816d7cdfa8a26d1671cab67122a8c5271a7.zip
cpython-1244c816d7cdfa8a26d1671cab67122a8c5271a7.tar.gz
cpython-1244c816d7cdfa8a26d1671cab67122a8c5271a7.tar.bz2
bpo-31904: Support signal module on VxWorks (GH-23391)
-rw-r--r--Lib/test/test_signal.py13
-rw-r--r--Misc/NEWS.d/next/Library/2020-11-19-16-14-36.bpo-31904.83kf9d.rst1
-rw-r--r--Modules/signalmodule.c4
3 files changed, 15 insertions, 3 deletions
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index 5a8ff36..6a43fe7 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -519,10 +519,14 @@ class WakeupSocketSignalTests(unittest.TestCase):
else:
write.setblocking(False)
- # Start with large chunk size to reduce the
- # number of send needed to fill the buffer.
written = 0
- for chunk_size in (2 ** 16, 2 ** 8, 1):
+ if sys.platform == "vxworks":
+ CHUNK_SIZES = (1,)
+ else:
+ # Start with large chunk size to reduce the
+ # number of send needed to fill the buffer.
+ CHUNK_SIZES = (2 ** 16, 2 ** 8, 1)
+ for chunk_size in CHUNK_SIZES:
chunk = b"x" * chunk_size
try:
while True:
@@ -595,6 +599,7 @@ class WakeupSocketSignalTests(unittest.TestCase):
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
+@unittest.skipUnless(hasattr(signal, 'siginterrupt'), "needs signal.siginterrupt()")
class SiginterruptTest(unittest.TestCase):
def readpipe_interrupted(self, interrupt):
@@ -680,6 +685,8 @@ class SiginterruptTest(unittest.TestCase):
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
+@unittest.skipUnless(hasattr(signal, 'getitimer') and hasattr(signal, 'setitimer'),
+ "needs signal.getitimer() and signal.setitimer()")
class ItimerTest(unittest.TestCase):
def setUp(self):
self.hndl_called = False
diff --git a/Misc/NEWS.d/next/Library/2020-11-19-16-14-36.bpo-31904.83kf9d.rst b/Misc/NEWS.d/next/Library/2020-11-19-16-14-36.bpo-31904.83kf9d.rst
new file mode 100644
index 0000000..e0ea23a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-19-16-14-36.bpo-31904.83kf9d.rst
@@ -0,0 +1 @@
+Support signal module on VxWorks.
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index fcc8f1c..7ac797a 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -120,7 +120,11 @@ static volatile struct {
#else
#define INVALID_FD (-1)
static volatile struct {
+#ifdef __VXWORKS__
+ int fd;
+#else
sig_atomic_t fd;
+#endif
int warn_on_full_buffer;
} wakeup = {.fd = INVALID_FD, .warn_on_full_buffer = 1};
#endif