[gnome-settings-daemon/benzea/ci-fixes: 18/19] tests: Fix close of invalid file descriptor




commit 28c6f318f43c45d838ce2cec2142a3d425bb96a7
Author: Benjamin Berg <bberg redhat com>
Date:   Wed Jul 21 12:36:55 2021 +0200

    tests: Fix close of invalid file descriptor
    
    The file descriptor may have been closed (and set to -1) already, catch
    this.

 tests/output_checker.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/tests/output_checker.py b/tests/output_checker.py
index 26f9217c..1680c2dc 100644
--- a/tests/output_checker.py
+++ b/tests/output_checker.py
@@ -67,7 +67,8 @@ class OutputChecker(object):
                     continue
 
                 # We get a bad file descriptor error when the outside closes the FD
-                os.close(self._pipe_fd_r)
+                if self._pipe_fd_r >= 0:
+                    os.close(self._pipe_fd_r)
                 self._pipe_fd_r = -1
                 self._lines_sem.release()
                 return


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]