mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Close #13022: _multiprocessing.recvfd() doesn't check that file descriptor was actually received
This commit is contained in:
parent
4ac5d2cda4
commit
c23484b21f
3 changed files with 31 additions and 0 deletions
|
@ -1574,6 +1574,23 @@ class _TestConnection(BaseTestCase):
|
|||
with open(test_support.TESTFN, "rb") as f:
|
||||
self.assertEqual(f.read(), b"bar")
|
||||
|
||||
@classmethod
|
||||
def _send_data_without_fd(self, conn):
|
||||
os.write(conn.fileno(), b"\0")
|
||||
|
||||
@unittest.skipIf(sys.platform == "win32", "doesn't make sense on Windows")
|
||||
def test_missing_fd_transfer(self):
|
||||
# Check that exception is raised when received data is not
|
||||
# accompanied by a file descriptor in ancillary data.
|
||||
if self.TYPE != 'processes':
|
||||
self.skipTest("only makes sense with processes")
|
||||
conn, child_conn = self.Pipe(duplex=True)
|
||||
|
||||
p = self.Process(target=self._send_data_without_fd, args=(child_conn,))
|
||||
p.daemon = True
|
||||
p.start()
|
||||
self.assertRaises(RuntimeError, reduction.recv_handle, conn)
|
||||
p.join()
|
||||
|
||||
class _TestListenerClient(BaseTestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue