start: simplify lxc_init()

parent b78872c0
...@@ -731,27 +731,21 @@ int lxc_init(const char *name, struct lxc_handler *handler) ...@@ -731,27 +731,21 @@ int lxc_init(const char *name, struct lxc_handler *handler)
handler->monitor_pid = lxc_raw_getpid(); handler->monitor_pid = lxc_raw_getpid();
status_fd = open("/proc/self/status", O_RDONLY | O_CLOEXEC); status_fd = open("/proc/self/status", O_RDONLY | O_CLOEXEC);
if (status_fd < 0) { if (status_fd < 0)
SYSERROR("Failed to open monitor status fd"); return log_error_errno(-1, errno, "Failed to open monitor status fd");
goto out_close_maincmd_fd;
}
lsm_init(); lsm_init();
TRACE("Initialized LSM"); TRACE("Initialized LSM");
ret = lxc_read_seccomp_config(conf); ret = lxc_read_seccomp_config(conf);
if (ret < 0) { if (ret < 0)
ERROR("Failed loading seccomp policy"); return log_error(-1, "Failed loading seccomp policy");
goto out_close_maincmd_fd;
}
TRACE("Read seccomp policy"); TRACE("Read seccomp policy");
/* Begin by setting the state to STARTING. */ /* Begin by setting the state to STARTING. */
ret = lxc_set_state(name, handler, STARTING); ret = lxc_set_state(name, handler, STARTING);
if (ret < 0) { if (ret < 0)
ERROR("Failed to set state to \"%s\"", lxc_state2str(STARTING)); return log_error(-1, "Failed to set state to \"%s\"", lxc_state2str(STARTING));
goto out_close_maincmd_fd;
}
TRACE("Set container state to \"STARTING\""); TRACE("Set container state to \"STARTING\"");
/* Start of environment variable setup for hooks. */ /* Start of environment variable setup for hooks. */
...@@ -824,7 +818,7 @@ int lxc_init(const char *name, struct lxc_handler *handler) ...@@ -824,7 +818,7 @@ int lxc_init(const char *name, struct lxc_handler *handler)
handler->sigfd = setup_signal_fd(&handler->oldmask); handler->sigfd = setup_signal_fd(&handler->oldmask);
if (handler->sigfd < 0) { if (handler->sigfd < 0) {
ERROR("Failed to setup SIGCHLD fd handler."); ERROR("Failed to setup SIGCHLD fd handler.");
goto out_delete_tty; goto out_aborting;
} }
TRACE("Set up signal fd"); TRACE("Set up signal fd");
...@@ -867,14 +861,9 @@ out_delete_terminal: ...@@ -867,14 +861,9 @@ out_delete_terminal:
out_restore_sigmask: out_restore_sigmask:
(void)pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL); (void)pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL);
out_delete_tty:
lxc_delete_tty(&conf->ttys);
out_aborting: out_aborting:
(void)lxc_set_state(name, handler, ABORTING); (void)lxc_set_state(name, handler, ABORTING);
out_close_maincmd_fd:
close_prot_errno_disarm(conf->maincmd_fd);
return -1; return -1;
} }
...@@ -1041,7 +1030,7 @@ void lxc_abort(const char *name, struct lxc_handler *handler) ...@@ -1041,7 +1030,7 @@ void lxc_abort(const char *name, struct lxc_handler *handler)
handler->pidfd, handler->pid); handler->pidfd, handler->pid);
} }
if (!ret || errno != ESRCH) if (!ret || errno != ESRCH && handler->pid > 0)
if (kill(handler->pid, SIGKILL)) if (kill(handler->pid, SIGKILL))
SYSWARN("Failed to send SIGKILL to %d", handler->pid); SYSWARN("Failed to send SIGKILL to %d", handler->pid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment