[CRIU] [PATCH 2/3] util: check that stdin are unused before closing

Andrey Vagin avagin at openvz.org
Tue Jan 15 09:44:20 EST 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 util.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/util.c b/util.c
index 82220ff..93678d2 100644
--- a/util.c
+++ b/util.c
@@ -532,13 +532,13 @@ int cr_system(int in, int out, int err, char *cmd, char *const argv[])
 		if (out == in)
 			out = DUP_SAFE(out, out_chld);
 
+		if (move_img_fd(&out, STDIN_FILENO) ||
+		    move_img_fd(&err, STDIN_FILENO))
+			goto out_chld;
+
 		if (in < 0) {
 			close(STDIN_FILENO);
 		} else {
-			if (move_img_fd(&out, STDIN_FILENO) ||
-			    move_img_fd(&err, STDIN_FILENO))
-				goto out_chld;
-
 			if (reopen_fd_as_nocheck(STDIN_FILENO, in))
 				goto out_chld;
 		}
-- 
1.7.11.7



More information about the CRIU mailing list