[lxc-devel] [lxc/master] lxc-attach: switch to attach_run_wait
brauner on Github
lxc-bot at linuxcontainers.org
Thu Feb 21 19:31:14 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190221/34f2b50a/attachment.bin>
-------------- next part --------------
From 8cddb10fe12487057f25dca9740942a27bfd4d2d Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 21 Feb 2019 20:28:24 +0100
Subject: [PATCH] lxc-attach: switch to attach_run_wait
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/tools/lxc_attach.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c
index d10b6ecc23..917cca2821 100644
--- a/src/lxc/tools/lxc_attach.c
+++ b/src/lxc/tools/lxc_attach.c
@@ -372,19 +372,23 @@ int main(int argc, char *argv[])
if (my_args.gid)
attach_options.gid = my_args.gid;
- if (command.program)
- ret = c->attach(c, lxc_attach_run_command, &command, &attach_options, &pid);
- else
+ if (command.program) {
+ ret = c->attach_run_wait(c, &attach_options, command.program,
+ (const char **)command.argv);
+ if (ret < 0)
+ goto out;
+ } else {
ret = c->attach(c, lxc_attach_run_shell, NULL, &attach_options, &pid);
- if (ret < 0)
- goto out;
+ if (ret < 0)
+ goto out;
- ret = lxc_wait_for_pid_status(pid);
- if (ret < 0)
- goto out;
+ ret = lxc_wait_for_pid_status(pid);
+ if (ret < 0)
+ goto out;
- if (WIFEXITED(ret))
- wexit = WEXITSTATUS(ret);
+ if (WIFEXITED(ret))
+ wexit = WEXITSTATUS(ret);
+ }
out:
lxc_container_put(c);
More information about the lxc-devel
mailing list