From: Dmitry V. Levin Date: Fri, 25 Aug 2006 07:42:05 +0000 (+0400) Subject: vzctl enter: Forward error messages from child process X-Git-Url: http://git.openvz.org/?p=vzctl;a=commitdiff;h=52b79699c9e5f7b9f3bebd6141395c374b80e22a vzctl enter: Forward error messages from child process vzctl: do_enter(): - In child, redirect stdout and stderr to pipe. - In parent, read child's output from pipe even if enter failed. Signed-off-by: Dmitry V. Levin --- Index: vzctl-3.0.11/src/enter.c =================================================================== --- vzctl-3.0.11.orig/src/enter.c +++ vzctl-3.0.11/src/enter.c @@ -231,6 +231,8 @@ int do_enter(vps_handler *h, envid_t vei close(in[1]); close(out[0]); close(st[0]); /* list of skipped fds -1 the end mark */ close_fds(1, in[0], out[1], st[1], h->vzfd, -1); + dup2(out[1], 1); + dup2(out[1], 2); if ((ret = vz_chroot(root))) goto err; ret = vz_env_create_ioctl(h, veid, VE_ENTER); @@ -297,7 +299,10 @@ err: raw_on(); e_loop(fileno(stdin), in[1], out[0], fileno(stdout)); } else { - fprintf(stdout, "enter failed\n"); + fprintf(stdout, "enter into VPS %d failed\n", veid); + set_not_blk(out[0]); + while (stdredir(out[0], fileno(stdout)) == 0) + ; } while ((waitpid(pid, &status, 0)) == -1) if (errno != EINTR)