[CRIU] [PATCH] util: cr_system_userns() should not affect log_fd
Andrew Vagin
avagin at virtuozzo.com
Fri Apr 22 10:00:12 PDT 2016
cr_system_userns moves files descriptors, so we can take log_fd
directly and need to duplicate it.
On Fri, Apr 22, 2016 at 07:48:32PM +0300, Andrey Vagin wrote:
> From: Andrew Vagin <avagin at virtuozzo.com>
>
> Fixes: 1dc2f87b33ce ("util: shutdown log in cr_system_userns if error fd is negative")
> Cc: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
> Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
> ---
> criu/util.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/criu/util.c b/criu/util.c
> index dae6031..e8ebe61 100644
> --- a/criu/util.c
> +++ b/criu/util.c
> @@ -609,8 +609,6 @@ int cr_system_userns(int in, int out, int err, char *cmd,
> pr_perror("fork() failed");
> goto out;
> } else if (pid == 0) {
> - bool stop_log_fd = false;
> -
> if (userns_pid > 0) {
> if (switch_ns(userns_pid, &user_ns_desc, NULL))
> goto out_chld;
> @@ -621,11 +619,9 @@ int cr_system_userns(int in, int out, int err, char *cmd,
> }
>
> if (out < 0)
> - out = log_get_fd();
> - if (err < 0) {
> - err = log_get_fd();
> - stop_log_fd = true;
> - }
> + out = DUP_SAFE(log_get_fd(), out_chld);
> + if (err < 0)
> + err = DUP_SAFE(log_get_fd(), out_chld);
>
> /*
> * out, err, in should be a separate fds,
> @@ -641,9 +637,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 {
> --
> 2.5.5
>
More information about the CRIU
mailing list