[lxc-devel] [PATCH] lxc_monitor: Check return value of write

Serge Hallyn serge.hallyn at ubuntu.com
Fri Dec 6 22:26:22 UTC 2013


Quoting Stéphane Graber (stgraber at ubuntu.com):
> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

one thing,

> ---
>  src/lxc/lxc_monitor.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
> index 63ab68b..92477e2 100644
> --- a/src/lxc/lxc_monitor.c
> +++ b/src/lxc/lxc_monitor.c
> @@ -93,11 +93,16 @@ int main(int argc, char *argv[])
>  
>  			fd = lxc_monitor_open(my_args.lxcpath[i]);
>  			if (fd < 0) {
> -				ERROR("Unable to open monitor on path:%s", my_args.lxcpath[i]);
> +				ERROR("Unable to open monitor on path: %s", my_args.lxcpath[i]);
>  				ret = EXIT_FAILURE;
>  				continue;
>  			}
> -			write(fd, "quit", 4);
> +			if (write(fd, "quit", 4) < 0) {
> +				ERROR("Unable to close monitor on path: %s", my_args.lxcpath[i]);

It'd probably be worth doing SYSERROR here instaed since you should
have a good errno from write().

> +				ret = EXIT_FAILURE;
> +				close(fd);
> +				continue;
> +			}
>  			close(fd);
>  		}
>  		return ret;
> -- 
> 1.8.5.1
> 
> 
> ------------------------------------------------------------------------------
> Sponsored by Intel(R) XDK 
> Develop, test and display web and hybrid apps with a single code base.
> Download it for free now!
> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list