From 8ce3d223585ad68171e51839403c1fa3cb625d87 Mon Sep 17 00:00:00 2001 From: Peter Gerber Date: Wed, 1 Feb 2023 20:23:17 +0100 Subject: [PATCH] Fix test hanging reading FIFO when `borg create` failed --- src/borg/testsuite/archiver/create_cmd.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/borg/testsuite/archiver/create_cmd.py b/src/borg/testsuite/archiver/create_cmd.py index 24e2f4461..f1db81928 100644 --- a/src/borg/testsuite/archiver/create_cmd.py +++ b/src/borg/testsuite/archiver/create_cmd.py @@ -784,6 +784,12 @@ class ArchiverTestCase(ArchiverTestCaseBase): try: self.cmd(f"--repo={self.repository_location}", "create", "--read-special", "test", "input/link_fifo") finally: + # In case `borg create` failed to open FIFO, read all data to avoid join() hanging. + fd = os.open(fifo_fn, os.O_RDONLY | os.O_NONBLOCK) + try: + os.read(fd, len(data)) + finally: + os.close(fd) t.join() with changedir("output"): self.cmd(f"--repo={self.repository_location}", "extract", "test")