mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-17 16:47:50 +00:00
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:
parent
1f78f31bcd
commit
b0057d1873
1 changed files with 2 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue