[CRIU] [PATCH] util: disable log service in cr_system_userns if error fd was -1

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Fri Apr 22 08:23:31 PDT 2016


In case of error fd was negative, log_fd is _moved_ as STDERR for the child.
After move, log_fd is closed, and thus log service is broken and any error
prints will disappear.
This patch disables log service, thus redirecting error output to STDERR
(which is log fd in this case).

Calling of log fini is:
1) to early: reopen_fd_as_nocheck will fail
2) to much: close_safe will print error message, because log fd was already
closed

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 criu/util.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/criu/util.c b/criu/util.c
index dae6031..12ce8b4 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -641,9 +641,6 @@ int cr_system_userns(int in, int out, int err, char *cmd,
 		    move_img_fd(&err, STDIN_FILENO))
 			goto out_chld;
 
-		if (stop_log_fd)
-			log_fini();
-
 		if (in < 0) {
 			close(STDIN_FILENO);
 		} else {
@@ -660,6 +657,9 @@ int cr_system_userns(int in, int out, int err, char *cmd,
 		if (reopen_fd_as_nocheck(STDERR_FILENO, err))
 			goto out_chld;
 
+		if (stop_log_fd)
+			clear_bit(LOG_FD_OFF, sfd_map);
+
 		execvp(cmd, argv);
 
 		pr_perror("exec failed");



More information about the CRIU mailing list