From 1f78f31bcd012540e1c92c947d9d6eca80ef7419 Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Mon, 6 Jul 2026 13:33:06 +0000 Subject: [PATCH] test/exhaustive: fix file handle leak in get_pipe_rw Use 'with' statement for opening /proc fdinfo to ensure the file handle is closed after iteration. Assisted-by: Claude Code (claude-opus-4-6) Signed-off-by: Adrian Reber --- test/exhaustive/pipe.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/exhaustive/pipe.py b/test/exhaustive/pipe.py index afe20846a..22b9317cc 100755 --- a/test/exhaustive/pipe.py +++ b/test/exhaustive/pipe.py @@ -61,14 +61,15 @@ def get_pipe_ino(pid, fd): def get_pipe_rw(pid, fd): - for l in open('/proc/%d/fdinfo/%d' % (pid, fd)): - if l.startswith('flags:'): - f = l.split(None, 1)[1][-2] - if f == '0': - return 0 # Read - elif f == '1': - return 1 # Write - break + with open('/proc/%d/fdinfo/%d' % (pid, fd)) as fh: + for l in fh: + if l.startswith('flags:'): + f = l.split(None, 1)[1][-2] + if f == '0': + return 0 # Read + elif f == '1': + return 1 # Write + break raise Exception('Unexpected fdinfo contents')