NULL,
};
char **init_cmd = NULL;
- int keepfds[3] = {-EBADF, -EBADF, -EBADF};
/* container does exist */
if (!c)
_exit(EXIT_FAILURE);
}
- keepfds[0] = handler->conf->maincmd_fd;
- keepfds[1] = handler->state_socket_pair[0];
- keepfds[2] = handler->state_socket_pair[1];
- ret = lxc_check_inherited(conf, true, keepfds, ARRAY_SIZE(keepfds));
+ ret = inherit_fds(handler, true);
if (ret < 0)
_exit(EXIT_FAILURE);
ret = 1;
goto on_error;
}
- } else {
- keepfds[1] = handler->state_socket_pair[0];
- keepfds[2] = handler->state_socket_pair[1];
}
- keepfds[0] = handler->conf->maincmd_fd;
- ret = lxc_check_inherited(conf, c->daemonize, keepfds, ARRAY_SIZE(keepfds));
+ ret = inherit_fds(handler, c->daemonize);
if (ret < 0) {
lxc_put_handler(handler);
ret = 1;
const char *name, struct lxc_conf *conf,
const char *lxcpath, bool daemonize)
{
+ int nr_keep_fds = 0;
int ret;
struct lxc_handler *handler;
TRACE("Created anonymous pair {%d,%d} of unix sockets",
handler->state_socket_pair[0],
handler->state_socket_pair[1]);
+ handler->keep_fds[nr_keep_fds++] = handler->state_socket_pair[0];
+ handler->keep_fds[nr_keep_fds++] = handler->state_socket_pair[1];
}
if (handler->conf->reboot == REBOOT_NONE) {
ERROR("Failed to set up command socket");
goto on_error;
}
+ handler->keep_fds[nr_keep_fds++] = handler->conf->maincmd_fd;
}
TRACE("Unix domain socket %d for command server is ready",
#include <sys/un.h>
#include "conf.h"
+#include "macro.h"
#include "namespace.h"
#include "state.h"
int exit_status;
struct cgroup_ops *cgroup_ops;
+
+ /* Internal fds that always need to stay open. */
+ int keep_fds[3];
};
struct execute_args {
*/
extern int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
int *fds_to_ignore, size_t len_fds);
+static inline int inherit_fds(struct lxc_handler *handler, bool closeall)
+{
+ return lxc_check_inherited(handler->conf, closeall, handler->keep_fds,
+ ARRAY_SIZE(handler->keep_fds));
+}
extern int __lxc_start(struct lxc_handler *, struct lxc_operations *, void *,
const char *, bool, int *);