Commit dd267776 by Bogdan Purcareata Committed by Stéphane Graber

add lxc.rebootsignal

Following the model of f0f1d8c0, add a reboot signal for special init processes that work on something other than SIGINT. Signed-off-by: 's avatarBogdan Purcareata <bogdan.purcareata@freescale.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 65f8fdda
......@@ -323,6 +323,7 @@ struct lxc_conf {
int maincmd_fd;
int autodev; // if 1, mount and fill a /dev at start
int haltsignal; // signal used to halt container
int rebootsignal; // signal used to reboot container
int stopsignal; // signal used to hard stop container
int kmsg; // if 1, create /dev/kmsg symlink
char *rcfile; // Copy of the top level rcfile we read
......
......@@ -98,6 +98,7 @@ static int config_includefile(const char *, const char *, struct lxc_conf *);
static int config_network_nic(const char *, const char *, struct lxc_conf *);
static int config_autodev(const char *, const char *, struct lxc_conf *);
static int config_haltsignal(const char *, const char *, struct lxc_conf *);
static int config_rebootsignal(const char *, const char *, struct lxc_conf *);
static int config_stopsignal(const char *, const char *, struct lxc_conf *);
static int config_start(const char *, const char *, struct lxc_conf *);
static int config_group(const char *, const char *, struct lxc_conf *);
......@@ -158,6 +159,7 @@ static struct lxc_config_t config[] = {
{ "lxc.include", config_includefile },
{ "lxc.autodev", config_autodev },
{ "lxc.haltsignal", config_haltsignal },
{ "lxc.rebootsignal", config_rebootsignal },
{ "lxc.stopsignal", config_stopsignal },
{ "lxc.start.auto", config_start },
{ "lxc.start.delay", config_start },
......@@ -1268,6 +1270,18 @@ static int config_haltsignal(const char *key, const char *value,
return 0;
}
static int config_rebootsignal(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
int sig_n = sig_parse(value);
if (sig_n < 0)
return -1;
lxc_conf->rebootsignal = sig_n;
return 0;
}
static int config_stopsignal(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
......
......@@ -1363,6 +1363,7 @@ free_tpath:
static bool lxcapi_reboot(struct lxc_container *c)
{
pid_t pid;
int rebootsignal = SIGINT;
if (!c)
return false;
......@@ -1371,7 +1372,9 @@ static bool lxcapi_reboot(struct lxc_container *c)
pid = c->init_pid(c);
if (pid <= 0)
return false;
if (kill(pid, SIGINT) < 0)
if (c->lxc_conf && c->lxc_conf->rebootsignal)
rebootsignal = c->lxc_conf->rebootsignal;
if (kill(pid, rebootsignal) < 0)
return false;
return true;
......
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