diff options
author | Helmut Grohne <helmut@subdivi.de> | 2025-05-04 20:09:02 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2025-05-04 20:09:02 +0200 |
commit | 1fa71c54e688b10c8c70dfb3cf7136cfb22f2085 (patch) | |
tree | 71d8ecfe82c9d57e2c1327103b13d483ffb9765f /tests | |
parent | 8e4f97aeffc4144e67c26b5a6f1943cefbc8790f (diff) | |
download | python-linuxnamespaces-1fa71c54e688b10c8c70dfb3cf7136cfb22f2085.tar.gz |
implement signalfd(2) and sigqueue(2) system calls
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_simple.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_simple.py b/tests/test_simple.py index eb03384..07a0740 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -5,6 +5,7 @@ import asyncio import errno import os import pathlib +import signal import socket import unittest @@ -92,6 +93,26 @@ class AsnycioTest(unittest.IsolatedAsyncioTestCase): efd.write() self.assertEqual(await fut, 1) + async def test_signalfd(self) -> None: + testsig = signal.SIGUSR1 + sfd = linuxnamespaces.SignalFD( + [testsig], linuxnamespaces.SignalFDFlags.NONBLOCK + ) + self.addCleanup(sfd.close) + oldmask = signal.pthread_sigmask(signal.SIG_SETMASK, [testsig]) + self.addCleanup(signal.pthread_sigmask, signal.SIG_SETMASK, oldmask) + fut = asyncio.ensure_future(sfd.aread()) + await asyncio.sleep(0.000001) # Let the loop run + self.assertFalse(fut.done()) + sigval = 123456789 + mypid = os.getpid() + linuxnamespaces.sigqueue(mypid, testsig, sigval) + siginfo = await fut + self.assertEqual(siginfo.ssi_signo, testsig) + self.assertEqual(siginfo.ssi_pid, mypid) + self.assertEqual(siginfo.ssi_uid, os.getuid()) + self.assertEqual(siginfo.ssi_int, sigval) + async def test_run_in_fork(self) -> None: with linuxnamespaces.EventFD( 0, linuxnamespaces.EventFDFlags.NONBLOCK |