[PATCH] vzctl enter: Forward error messages from child process [message #5636] |
Thu, 24 August 2006 22:39 |
ldv
Messages: 24 Registered: June 2006
|
Junior Member |
|
|
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 <ldv@altlinux.org>
---
I need to obtain more information about vzctl enter failure.
For example, if dev/ptmx is not available inside container, vzctl enter
just fails with short "enter failed" message.
This patch forwards error messages issued by child process, e.g.
# vzctl enter 1234
enter into VPS 1234 failed
Unable to open pty: No such file or directory
src/enter.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/enter.c b/src/enter.c
index 69cdd02..e0013df 100644
--- a/src/enter.c
+++ b/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)
--
ldv
|
|
|