Skip to content

Instantly share code, notes, and snippets.

@jordemort
Created October 26, 2017 19:47
Show Gist options
  • Save jordemort/44603d34bb602bb15fa19e4fcd1b2089 to your computer and use it in GitHub Desktop.
Save jordemort/44603d34bb602bb15fa19e4fcd1b2089 to your computer and use it in GitHub Desktop.
Attempt to allow lxc-attach to attach to running containers
diff -dpru lxc-2.0.9/src/lxc/tools/lxc_attach.c lxc-2.0.9.attach/src/lxc/tools/lxc_attach.c
--- lxc-2.0.9/src/lxc/tools/lxc_attach.c 2017-10-19 12:13:25.000000000 -0500
+++ lxc-2.0.9.attach/src/lxc/tools/lxc_attach.c 2017-10-25 14:41:27.263268277 -0500
@@ -431,8 +431,8 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- if (!c->is_defined(c)) {
- fprintf(stderr, "Error: container %s is not defined\n", c->name);
+ if (!(c->is_defined(c) || c->is_running(c))) {
+ fprintf(stderr, "Error: container %s is not defined or running\n", c->name);
lxc_container_put(c);
exit(EXIT_FAILURE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment