return ret;
}
-extern int lxc_command(const char *name, struct lxc_command *command,
- int *stopped)
+static int __lxc_command(const char *name, struct lxc_command *command,
+ int *stopped, int stay_connected)
{
int sock, ret = -1;
char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = { 0 };
ret = receive_answer(sock, &command->answer);
out:
- close(sock);
+ if (!stay_connected || ret < 0)
+ close(sock);
+
return ret;
}
+extern int lxc_command(const char *name,
+ struct lxc_command *command, int *stopped)
+{
+ return __lxc_command(name, command, stopped, 0);
+}
+
+extern int lxc_command_connected(const char *name,
+ struct lxc_command *command, int *stopped)
+{
+ return __lxc_command(name, command, stopped, 1);
+}
+
+
pid_t get_init_pid(const char *name)
{
struct lxc_command command = {
};
extern pid_t get_init_pid(const char *name);
+
extern int lxc_command(const char *name, struct lxc_command *command,
int *stopped);
+extern int lxc_command_connected(const char *name, struct lxc_command *command,
+ int *stopped);
+
struct lxc_epoll_descr;
struct lxc_handler;
.request = { .type = LXC_COMMAND_TTY, .data = ttynum },
};
- ret = lxc_command(name, &command, &stopped);
+ ret = lxc_command_connected(name, &command, &stopped);
if (ret < 0 && stopped) {
ERROR("'%s' is stopped", name);
return -1;