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

Stéphane Graber stgraber at ubuntu.com
Fri Dec 6 22:19:54 UTC 2013


Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 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]);
+				ret = EXIT_FAILURE;
+				close(fd);
+				continue;
+			}
 			close(fd);
 		}
 		return ret;
-- 
1.8.5.1





More information about the lxc-devel mailing list