Skip to content

Commit d9ad171

Browse files
authored
gh-149879: Fix test_signal on Cygwin (#149896)
* Check for SIG_BLOCK instead of pthread_sigmask() to decide if SIG_BLOCK, SIG_UNBLOCK and SIG_SETMASK constants should be converted to enums. * Skip ITIMER_VIRTUAL and ITIMER_PROF tests on Cygwin: setitimer() fails with ItimerError(EINVAL).
1 parent 9ee9f58 commit d9ad171

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/signal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'Handlers', __name__,
1616
lambda name: name in ('SIG_DFL', 'SIG_IGN'))
1717

18-
if 'pthread_sigmask' in _globals:
18+
if 'SIG_BLOCK' in _globals:
1919
_IntEnum._convert_(
2020
'Sigmasks', __name__,
2121
lambda name: name in ('SIG_BLOCK', 'SIG_UNBLOCK', 'SIG_SETMASK'))

Lib/test/test_signal.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,8 @@ def test_itimer_real(self):
833833
# Issue 3864, unknown if this affects earlier versions of freebsd also
834834
@unittest.skipIf(sys.platform in ('netbsd5',) or is_apple_mobile,
835835
'itimer not reliable (does not mix well with threading) on some BSDs.')
836+
@unittest.skipIf(sys.platform == 'cygwin',
837+
"Cygwin doesn't support ITIMER_VIRTUAL")
836838
def test_itimer_virtual(self):
837839
self.itimer = signal.ITIMER_VIRTUAL
838840
signal.signal(signal.SIGVTALRM, self.sig_vtalrm)
@@ -850,6 +852,8 @@ def test_itimer_virtual(self):
850852
# and the handler should have been called
851853
self.assertEqual(self.hndl_called, True)
852854

855+
@unittest.skipIf(sys.platform == 'cygwin',
856+
"Cygwin doesn't support ITIMER_PROF")
853857
def test_itimer_prof(self):
854858
self.itimer = signal.ITIMER_PROF
855859
signal.signal(signal.SIGPROF, self.sig_prof)

0 commit comments

Comments
 (0)