[CRIU] [PATCH] test: Don't leak file descriptor
Radostin Stoyanov
rstoyanov1 at gmail.com
Mon Jun 4 09:43:21 MSK 2018
Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
---
test/inhfd/fifo.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/test/inhfd/fifo.py b/test/inhfd/fifo.py
index a4b4fc84..c3e8fb0b 100755
--- a/test/inhfd/fifo.py
+++ b/test/inhfd/fifo.py
@@ -14,14 +14,14 @@ def create_fds():
os.rmdir(tdir)
mnt_id = -1;
- f = open("/proc/self/fdinfo/%d" % fd1.fileno())
- for l in f:
- l = l.split()
- if l[0] == "mnt_id:":
- mnt_id = int(l[1])
- break
- else:
- raise Exception("Unable to find mnt_id")
+ with open("/proc/self/fdinfo/%d" % fd1.fileno()) as f:
+ for l in f:
+ l = l.split()
+ if l[0] == "mnt_id:":
+ mnt_id = int(l[1])
+ break
+ else:
+ raise Exception("Unable to find mnt_id")
global id_str
id_str = "file[%x:%x]" % (mnt_id, os.fstat(fd1.fileno()).st_ino)
--
2.17.1
More information about the CRIU
mailing list