test/rpc: fix file handle leak in status fd reader

Use 'with' statement instead of manual open/read/close to
ensure the file is closed if read() raises an exception.

Assisted-by: Claude Code (claude-opus-4-6)
Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
Adrian Reber 2026-07-06 13:33:26 +00:00 committed by Radostin Stoyanov
parent 1f78f31bcd
commit b0057d1873

View file

@ -7,9 +7,8 @@
import sys
f = open(sys.argv[1])
r = f.read(1)
f.close()
with open(sys.argv[1]) as f:
r = f.read(1)
if r == '\0':
sys.exit(0)