mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 14:30:32 +00:00
Merge pull request #2530 from brauner/2018-08-16/minor_fixes
lxccontainer: minor fixes
This commit is contained in:
commit
03eda56551
@ -970,10 +970,15 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
|
|||||||
/* We don't really care if this doesn't print all the
|
/* We don't really care if this doesn't print all the
|
||||||
* characters. All that it means is that the proctitle will be
|
* characters. All that it means is that the proctitle will be
|
||||||
* ugly. Similarly, we also don't care if setproctitle() fails.
|
* ugly. Similarly, we also don't care if setproctitle() fails.
|
||||||
* */
|
*/
|
||||||
(void)snprintf(title, sizeof(title), "[lxc monitor] %s %s", c->config_path, c->name);
|
ret = snprintf(title, sizeof(title), "[lxc monitor] %s %s", c->config_path, c->name);
|
||||||
INFO("Attempting to set proc title to %s", title);
|
if (ret > 0) {
|
||||||
(void)setproctitle(title);
|
ret = setproctitle(title);
|
||||||
|
if (ret < 0)
|
||||||
|
INFO("Failed to set process title to %s", title);
|
||||||
|
else
|
||||||
|
INFO("Set process title to %s", title);
|
||||||
|
}
|
||||||
|
|
||||||
/* We fork() a second time to be reparented to init. Like
|
/* We fork() a second time to be reparented to init. Like
|
||||||
* POSIX's daemon() function we change to "/" and redirect
|
* POSIX's daemon() function we change to "/" and redirect
|
||||||
@ -1020,17 +1025,15 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
|
|||||||
ret = setsid();
|
ret = setsid();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
TRACE("Process %d is already process group leader", lxc_raw_getpid());
|
TRACE("Process %d is already process group leader", lxc_raw_getpid());
|
||||||
} else {
|
} else if (!am_single_threaded()) {
|
||||||
if (!am_single_threaded()) {
|
ERROR("Cannot start non-daemonized container when threaded");
|
||||||
ERROR("Cannot start non-daemonized container when threaded");
|
free_init_cmd(init_cmd);
|
||||||
free_init_cmd(init_cmd);
|
lxc_free_handler(handler);
|
||||||
lxc_free_handler(handler);
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need to write PID file after daemonize, so we always
|
/* We need to write PID file after daemonize, so we always write the
|
||||||
* write the right PID.
|
* right PID.
|
||||||
*/
|
*/
|
||||||
if (c->pidfile) {
|
if (c->pidfile) {
|
||||||
int ret, w;
|
int ret, w;
|
||||||
@ -1054,7 +1057,7 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
|
|||||||
free_init_cmd(init_cmd);
|
free_init_cmd(init_cmd);
|
||||||
lxc_free_handler(handler);
|
lxc_free_handler(handler);
|
||||||
|
|
||||||
SYSERROR("Failed to write '%s'", c->pidfile);
|
SYSERROR("Failed to write monitor pid to \"%s\"", c->pidfile);
|
||||||
|
|
||||||
if (c->daemonize)
|
if (c->daemonize)
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
@ -1069,7 +1072,7 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
|
|||||||
if (conf->monitor_unshare) {
|
if (conf->monitor_unshare) {
|
||||||
ret = unshare(CLONE_NEWNS);
|
ret = unshare(CLONE_NEWNS);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
SYSERROR("failed to unshare mount namespace");
|
SYSERROR("Failed to unshare mount namespace");
|
||||||
lxc_free_handler(handler);
|
lxc_free_handler(handler);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
Loading…
Reference in New Issue
Block a user