</variablelist>
</refsect1>
+ <refsect1>
+ <title>Exit value</title>
+
+ <variablelist>
+
+ <varlistentry>
+ <term>0</term>
+ <listitem>
+ <para>
+ The container was successfully stopped.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>1</term>
+ <listitem>
+ <para>
+ An error occurred while stopping the container.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>2</term>
+ <listitem>
+ <para>
+ The specified container exists but was not running.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ </refsect1>
<refsect1>
<title>Diagnostic</title>
ret = lxc_caps_init();
if (ret)
- return ret;
+ return 1;
ret = lxc_arguments_parse(&my_args, argc, argv);
if (ret)
- return ret;
+ return 1;
if (!my_args.log_file)
my_args.log_file = "none";
ret = lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
my_args.progname, my_args.quiet, my_args.lxcpath[0]);
if (ret)
- return ret;
+ return 1;
lxc_log_options_no_override();
if (remount_sys_proc)
}
if (ret < 0)
- return -1;
+ return 1;
ret = lxc_wait_for_pid_status(pid);
if (ret < 0)
- return -1;
+ return 1;
if (WIFEXITED(ret))
return WEXITSTATUS(ret);
- return -1;
+ return 1;
}
struct lxc_container *c;
if (lxc_arguments_parse(&my_args, argc, argv))
- return -1;
+ return 1;
if (!my_args.log_file)
my_args.log_file = "none";
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
- return -1;
+ return 1;
lxc_log_options_no_override();
state_object = my_args.argv[0];
c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c)
- return -1;
+ return 1;
if (!c->may_control(c)) {
ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name);
lxc_container_put(c);
- return -1;
+ return 1;
}
if (!c->is_running(c)) {
ERROR("'%s:%s' is not running", my_args.lxcpath[0], my_args.name);
lxc_container_put(c);
- return -1;
+ return 1;
}
if ((my_args.argc) > 1) {
ERROR("failed to assign '%s' value to '%s' for '%s'",
value, state_object, my_args.name);
lxc_container_put(c);
- return -1;
+ return 1;
}
} else {
int len = 4096;
ERROR("failed to retrieve value of '%s' for '%s:%s'",
state_object, my_args.lxcpath[0], my_args.name);
lxc_container_put(c);
- return -1;
+ return 1;
}
printf("%*s", ret, buffer);
}
if (!c1->may_control(c1)) {
fprintf(stderr, "Insufficent privileges to control %s\n", orig);
lxc_container_put(c1);
- return -1;
+ return 1;
}
if (!c1->is_defined(c1)) {
}
}
printf("Unknown configuration item: %s\n", argv[1]);
- exit(-1);
+ exit(1);
}
if (!c->may_control(c)) {
fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
lxc_container_put(c);
- return -1;
+ exit(EXIT_FAILURE);
}
if (!c->is_running(c)) {
if (!c->may_control(c)) {
fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
lxc_container_put(c);
- return -1;
+ exit(1);
}
if (!c->is_defined(c)) {
}
lxc_container_put(c);
- return 0;
+ exit(0);
}
{
char *rcfile;
struct lxc_conf *conf;
+ int ret;
lxc_list_init(&defines);
if (lxc_caps_init())
- return -1;
+ return 1;
if (lxc_arguments_parse(&my_args, argc, argv))
- return -1;
+ return 1;
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
- return -1;
+ return 1;
lxc_log_options_no_override();
/* rcfile is specified in the cli option */
rc = asprintf(&rcfile, "%s/%s/config", my_args.lxcpath[0], my_args.name);
if (rc == -1) {
SYSERROR("failed to allocate memory");
- return -1;
+ return 1;
}
/* container configuration does not exist */
conf = lxc_conf_init();
if (!conf) {
ERROR("failed to initialize configuration");
- return -1;
+ return 1;
}
if (rcfile && lxc_config_read(rcfile, conf)) {
ERROR("failed to read configuration file");
- return -1;
+ return 1;
}
if (lxc_config_define_load(&defines, conf))
- return -1;
+ return 1;
- return lxc_execute(my_args.name, my_args.argv, my_args.quiet, conf, my_args.lxcpath[0]);
+ ret = lxc_execute(my_args.name, my_args.argv, my_args.quiet, conf, my_args.lxcpath[0]);
+ if (ret < 0)
+ return 1;
+ return ret;
}
if (!c->may_control(c)) {
ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name);
lxc_container_put(c);
- return -1;
+ exit(1);
}
if (!c->freeze(c)) {
lxc_container_put(c);
- return 0;
+ exit(0);
}
}
}
out:
- return err;
+ if (err < 0)
+ exit(EXIT_FAILURE);
+ exit(err);
}
int len, rc, i, nfds = -1;
if (lxc_arguments_parse(&my_args, argc, argv))
- return -1;
+ return 1;
if (!my_args.log_file)
my_args.log_file = "none";
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
- return -1;
+ return 1;
lxc_log_options_no_override();
if (quit_monitord) {
regexp = malloc(len + 3);
if (!regexp) {
ERROR("failed to allocate memory");
- return -1;
+ return 1;
}
rc = snprintf(regexp, len, "^%s$", my_args.name);
if (rc < 0 || rc >= len) {
ERROR("Name too long");
free(regexp);
- return -1;
+ return 1;
}
if (regcomp(&preg, regexp, REG_NOSUB|REG_EXTENDED)) {
ERROR("failed to compile the regex '%s'", my_args.name);
free(regexp);
- return -1;
+ return 1;
}
free(regexp);
fd = lxc_monitor_open(my_args.lxcpath[i]);
if (fd < 0) {
regfree(&preg);
- return -1;
+ return 1;
}
FD_SET(fd, &rfds);
if (fd > nfds)
if (lxc_monitor_read_fdset(&rfds, nfds, &msg, -1) < 0) {
regfree(&preg);
- return -1;
+ return 1;
}
msg.name[sizeof(msg.name)-1] = '\0';
sigdelset(&mask, SIGTERM) ||
sigprocmask(SIG_BLOCK, &mask, NULL)) {
SYSERROR("failed to set signal mask");
- return -1;
+ return 1;
}
signal(SIGILL, lxc_monitord_sig_handler);
ret = EXIT_SUCCESS;
NOTICE("monitor exiting");
out:
- return ret;
+ if (ret == 0)
+ return 0;
+ return 1;
}
if (my_args.argc > 1) {
ERROR("Too many arguments");
- return -1;
+ exit(1);
}
if (my_args.argc == 1)
newname = my_args.argv[0];
if (!c->may_control(c)) {
fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
lxc_container_put(c);
- return -1;
+ exit(1);
}
switch(action) {
lxc_container_put(c);
- exit(ret);
+ if (ret == 0)
+ exit(EXIT_SUCCESS);
+ exit(EXIT_FAILURE);
}
out:
lxc_container_put(c);
+ if (ret < 0)
+ return 1;
return ret;
}
if (!c->may_control(c)) {
ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name);
lxc_container_put(c);
- return -1;
+ exit(1);
}
if (!c->unfreeze(c)) {
lxc_container_put(c);
- return 0;
+ exit(0);
}
ret = lxc_caps_init();
if (ret)
- return ret;
+ return 1;
ret = lxc_fill_namespace_flags(namespaces, &flags);
if (ret)
pid = lxc_clone(do_start, &start_arg, flags);
if (pid < 0) {
ERROR("failed to clone");
- return -1;
+ return 1;
}
if (my_iflist) {
if (waitpid(pid, &status, 0) < 0) {
ERROR("failed to wait for '%d'", pid);
- return -1;
+ return 1;
}
return lxc_error_set_and_log(pid, status);
if ((ret = waitpid(pid, &status, __WALL)) < 0) {
printf("waitpid() returns %d, errno %d\n", ret, errno);
- exit(ret);
+ exit(1);
}
exit(WEXITSTATUS(status));
struct lxc_container *c;
if (lxc_arguments_parse(&my_args, argc, argv))
- return -1;
+ return 1;
if (!my_args.log_file)
my_args.log_file = "none";
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
- return -1;
+ return 1;
lxc_log_options_no_override();
c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c)
- return -1;
+ return 1;
if (!c->may_control(c)) {
fprintf(stderr, "Insufficent privileges to control %s\n", c->name);
lxc_container_put(c);
- return -1;
+ return 1;
}
if (!c->wait(c, my_args.states, my_args.timeout)) {
lxc_container_put(c);
- return -1;
+ return 1;
}
return 0;
}