[CRIU] [PATCH] test: Don't leak file descriptor

Andrei Vagin avagin at virtuozzo.com
Fri Jun 8 10:00:47 MSK 2018


Applied, thanks
On Mon, Jun 04, 2018 at 07:43:21AM +0100, Radostin Stoyanov wrote:
> 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
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list