Skip to content

Commit f81c044

Browse files
committed
..
1 parent a0b7a56 commit f81c044

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

core/process.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,29 +2022,12 @@ def NumRunning(self):
20222022
NO_ARG = -20
20232023

20242024

2025-
_SIGNAL_MESSAGES = {
2026-
SIGSEGV: 'Segmentation fault',
2027-
SIGABRT: 'Aborted',
2028-
SIGILL: 'Illegal instruction',
2029-
SIGFPE: 'Floating point exception',
2030-
SIGBUS: 'Bus error',
2031-
SIGQUIT: 'Quit',
2032-
SIGTERM: 'Terminated',
2033-
SIGKILL: 'Killed',
2034-
}
2035-
2036-
20372025
def GetSignalMessage(sig_num):
20382026
# type: (int) -> Optional[str]
2039-
"""Get signal message from libc or fallback to hard-coded."""
2040-
msg = None # type: Optional[str]
2041-
2027+
"""Get signal message from libc."""
20422028
if mylib.PYTHON:
2043-
msg = libc.strsignal(sig_num)
2044-
if msg is not None:
2045-
return msg
2046-
2047-
return _SIGNAL_MESSAGES.get(sig_num)
2029+
return libc.strsignal(sig_num)
2030+
return None
20482031

20492032

20502033
class Waiter(object):

pyext/libc_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"""
1313
import unittest
1414
import sys
15+
import signal
1516

1617
import libc # module under test
1718

@@ -368,10 +369,10 @@ def testSleepUntilError(self):
368369
# Not testing errno case
369370

370371
def testStrsignal(self):
371-
self.assertEqual('Segmentation fault', libc.strsignal(11))
372-
self.assertEqual('Aborted', libc.strsignal(6))
373-
self.assertEqual('Illegal instruction', libc.strsignal(4))
374-
self.assertEqual('Terminated', libc.strsignal(15))
372+
self.assertEqual('Segmentation fault', libc.strsignal(signal.SIGSEGV))
373+
self.assertEqual('Aborted', libc.strsignal(signal.SIGABRT))
374+
self.assertEqual('Illegal instruction', libc.strsignal(signal.SIGILL))
375+
self.assertEqual('Terminated', libc.strsignal(signal.SIGTERM))
375376

376377
with self.assertRaises(ValueError):
377378
libc.strsignal(999)

0 commit comments

Comments
 (0)