Unverified Commit a33b05fa by Long Wang Committed by Stéphane Graber

lxc-init: non-functional changes

This patch mainly update the message format to: * upper the first letter * end without a dot all changes are relate to `lxc-init` Signed-off-by: 's avatarLong Wang <w@laoqinren.net>
parent ef3db30f
...@@ -46,12 +46,12 @@ extern int lxc_error_set_and_log(int pid, int status) ...@@ -46,12 +46,12 @@ extern int lxc_error_set_and_log(int pid, int status)
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
ret = WEXITSTATUS(status); ret = WEXITSTATUS(status);
if (ret) if (ret)
INFO("Child <%d> ended on error (%d).", pid, ret); INFO("Child <%d> ended on error (%d)", pid, ret);
} }
if (WIFSIGNALED(status)) { if (WIFSIGNALED(status)) {
int signal = WTERMSIG(status); int signal = WTERMSIG(status);
INFO("Child <%d> ended on signal (%d).", pid, signal); INFO("Child <%d> ended on signal (%d)", pid, signal);
} }
return ret; return ret;
......
...@@ -30,10 +30,10 @@ static int mount_fs(const char *source, const char *target, const char *type) ...@@ -30,10 +30,10 @@ static int mount_fs(const char *source, const char *target, const char *type)
{ {
/* the umount may fail */ /* the umount may fail */
if (umount(target)) if (umount(target))
WARN("failed to unmount %s : %s", target, strerror(errno)); WARN("Failed to unmount %s : %s", target, strerror(errno));
if (mount(source, target, type, 0, NULL)) { if (mount(source, target, type, 0, NULL)) {
ERROR("failed to mount %s : %s", target, strerror(errno)); ERROR("Failed to mount %s : %s", target, strerror(errno));
return -1; return -1;
} }
...@@ -45,26 +45,26 @@ static int mount_fs(const char *source, const char *target, const char *type) ...@@ -45,26 +45,26 @@ static int mount_fs(const char *source, const char *target, const char *type)
extern void lxc_setup_fs(void) extern void lxc_setup_fs(void)
{ {
if (mount_fs("proc", "/proc", "proc")) if (mount_fs("proc", "/proc", "proc"))
INFO("failed to remount proc"); INFO("Failed to remount proc");
/* if /dev has been populated by us, /dev/shm does not exist */ /* if /dev has been populated by us, /dev/shm does not exist */
if (access("/dev/shm", F_OK) && mkdir("/dev/shm", 0777)) if (access("/dev/shm", F_OK) && mkdir("/dev/shm", 0777))
INFO("failed to create /dev/shm"); INFO("Failed to create /dev/shm");
/* if we can't mount /dev/shm, continue anyway */ /* if we can't mount /dev/shm, continue anyway */
if (mount_fs("shmfs", "/dev/shm", "tmpfs")) if (mount_fs("shmfs", "/dev/shm", "tmpfs"))
INFO("failed to mount /dev/shm"); INFO("Failed to mount /dev/shm");
/* If we were able to mount /dev/shm, then /dev exists */ /* If we were able to mount /dev/shm, then /dev exists */
/* Sure, but it's read-only per config :) */ /* Sure, but it's read-only per config :) */
if (access("/dev/mqueue", F_OK) && mkdir("/dev/mqueue", 0666)) { if (access("/dev/mqueue", F_OK) && mkdir("/dev/mqueue", 0666)) {
DEBUG("failed to create '/dev/mqueue'"); DEBUG("Failed to create '/dev/mqueue'");
return; return;
} }
/* continue even without posix message queue support */ /* continue even without posix message queue support */
if (mount_fs("mqueue", "/dev/mqueue", "mqueue")) if (mount_fs("mqueue", "/dev/mqueue", "mqueue"))
INFO("failed to mount /dev/mqueue"); INFO("Failed to mount /dev/mqueue");
} }
static char *copy_global_config_value(char *p) static char *copy_global_config_value(char *p)
......
...@@ -119,7 +119,7 @@ int main(int argc, char *argv[]) ...@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
lxc_log_options_no_override(); lxc_log_options_no_override();
if (!argv[optind]) { if (!argv[optind]) {
ERROR("missing command to launch"); ERROR("Missing command to launch");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -134,7 +134,7 @@ int main(int argc, char *argv[]) ...@@ -134,7 +134,7 @@ int main(int argc, char *argv[])
sigdelset(&mask, SIGSEGV) || sigdelset(&mask, SIGSEGV) ||
sigdelset(&mask, SIGBUS) || sigdelset(&mask, SIGBUS) ||
sigprocmask(SIG_SETMASK, &mask, &omask)) { sigprocmask(SIG_SETMASK, &mask, &omask)) {
SYSERROR("failed to set signal mask"); SYSERROR("Failed to set signal mask");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -160,14 +160,14 @@ int main(int argc, char *argv[]) ...@@ -160,14 +160,14 @@ int main(int argc, char *argv[])
sigdelset(&act.sa_mask, SIGBUS) || sigdelset(&act.sa_mask, SIGBUS) ||
sigdelset(&act.sa_mask, SIGSTOP) || sigdelset(&act.sa_mask, SIGSTOP) ||
sigdelset(&act.sa_mask, SIGKILL)) { sigdelset(&act.sa_mask, SIGKILL)) {
ERROR("failed to set signal"); ERROR("Failed to set signal");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
act.sa_flags = 0; act.sa_flags = 0;
act.sa_handler = interrupt_handler; act.sa_handler = interrupt_handler;
if (sigaction(i, &act, NULL) && errno != EINVAL) { if (sigaction(i, &act, NULL) && errno != EINVAL) {
SYSERROR("failed to sigaction"); SYSERROR("Failed to sigaction");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
...@@ -175,32 +175,30 @@ int main(int argc, char *argv[]) ...@@ -175,32 +175,30 @@ int main(int argc, char *argv[])
lxc_setup_fs(); lxc_setup_fs();
pid = fork(); pid = fork();
if (pid < 0) if (pid < 0)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
if (!pid) { if (!pid) {
/* restore default signal handlers */ /* restore default signal handlers */
for (i = 1; i < NSIG; i++) for (i = 1; i < NSIG; i++)
signal(i, SIG_DFL); signal(i, SIG_DFL);
if (sigprocmask(SIG_SETMASK, &omask, NULL)) { if (sigprocmask(SIG_SETMASK, &omask, NULL)) {
SYSERROR("failed to set signal mask"); SYSERROR("Failed to set signal mask");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
NOTICE("about to exec '%s'", aargv[0]); NOTICE("About to exec '%s'", aargv[0]);
execvp(aargv[0], aargv); execvp(aargv[0], aargv);
ERROR("failed to exec: '%s' : %s", aargv[0], strerror(errno)); ERROR("Failed to exec: '%s' : %s", aargv[0], strerror(errno));
exit(err); exit(err);
} }
/* let's process the signals now */ /* let's process the signals now */
if (sigdelset(&omask, SIGALRM) || if (sigdelset(&omask, SIGALRM) ||
sigprocmask(SIG_SETMASK, &omask, NULL)) { sigprocmask(SIG_SETMASK, &omask, NULL)) {
SYSERROR("failed to set signal mask"); SYSERROR("Failed to set signal mask");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -214,10 +212,8 @@ int main(int argc, char *argv[]) ...@@ -214,10 +212,8 @@ int main(int argc, char *argv[])
pid_t waited_pid; pid_t waited_pid;
switch (was_interrupted) { switch (was_interrupted) {
case 0: case 0:
break; break;
case SIGPWR: case SIGPWR:
case SIGTERM: case SIGTERM:
if (!shutdown) { if (!shutdown) {
...@@ -226,11 +222,9 @@ int main(int argc, char *argv[]) ...@@ -226,11 +222,9 @@ int main(int argc, char *argv[])
alarm(1); alarm(1);
} }
break; break;
case SIGALRM: case SIGALRM:
kill(-1, SIGKILL); kill(-1, SIGKILL);
break; break;
default: default:
kill(pid, was_interrupted); kill(pid, was_interrupted);
break; break;
...@@ -244,7 +238,7 @@ int main(int argc, char *argv[]) ...@@ -244,7 +238,7 @@ int main(int argc, char *argv[])
if (errno == EINTR) if (errno == EINTR)
continue; continue;
ERROR("failed to wait child : %s", ERROR("Failed to wait child : %s",
strerror(errno)); strerror(errno));
goto out; goto out;
} }
......
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