<para>
<command>lxc-stop</command> reboots, cleanly shuts down, or kills
all the processes inside the container. By default, it will
- request a clean shutdown of the container (by sending SIGPWR to
- the container), wait 60 seconds for the container to exit, and
- returns. If the container fails to cleanly exit, then after 60
- seconds the container will be sent the
- <command>lxc.stopsignal</command> to force it to shut down. If
- <command>lxc.stopsignal</command> is not specified, the signal sent is
- SIGKILL.
+ request a clean shutdown of the container by sending
+ <command>lxc.haltsignal</command> (defaults to SIGPWR) to
+ the container's init process, waiting up to 60 seconds for the container
+ to exit, and then returning. If the container fails to cleanly exit in
+ 60 seconds, it will be sent the <command>lxc.stopsignal</command>
+ (defaults to SIGKILL) to force it to shut down.
</para>
<para>
The <optional>-W</optional>, <optional>-r</optional>,
</variablelist>
</refsect2>
+ <refsect2>
+ <title>Halt signal</title>
+ <para>
+ Allows one to specify signal name or number, sent by lxc-stop to the
+ container's init process to cleanly shutdown the container. Different
+ init systems could use different signals to perform clean shutdown
+ sequence. This option allows the signal to be specified in kill(1)
+ fashion, e.g. SIGPWR, SIGRTMIN+14, SIGRTMAX-10 or plain number. The
+ default signal is SIGPWR.
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ <option>lxc.haltsignal</option>
+ </term>
+ <listitem>
+ <para>
+ specify the signal used to halt the container
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect2>
+
<refsect2>
<title>Stop signal</title>
<para>
- Allows one to specify signal name or number, sent by lxc-stop to
- shutdown the container. Different init systems could use
- different signals to perform clean shutdown sequence. Option
- allows signal to be specified in kill(1) fashion, e.g.
- SIGKILL, SIGRTMIN+14, SIGRTMAX-10 or plain number.
+ Allows one to specify signal name or number, sent by lxc-stop to forcibly
+ shutdown the container. This option allows signal to be specified in
+ kill(1) fashion, e.g. SIGKILL, SIGRTMIN+14, SIGRTMAX-10 or plain number.
+ The default signal is SIGKILL.
</para>
<variablelist>
<varlistentry>
#endif
int maincmd_fd;
int autodev; // if 1, mount and fill a /dev at start
- int stopsignal; // signal used to stop container
+ int haltsignal; // signal used to halt 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
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_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 *);
{ "lxc.seccomp", config_seccomp },
{ "lxc.include", config_includefile },
{ "lxc.autodev", config_autodev },
+ { "lxc.haltsignal", config_haltsignal },
{ "lxc.stopsignal", config_stopsignal },
{ "lxc.start.auto", config_start },
{ "lxc.start.delay", config_start },
return sig_n;
}
+static const char *sig_name(int signum) {
+ int n;
+
+ for (n = 0; n < sizeof(signames) / sizeof((signames)[0]); n++) {
+ if (n == signames[n].num)
+ return signames[n].name;
+ }
+ return "";
+}
+
static int sig_parse(const char *signame) {
int n;
return -1;
}
+static int config_haltsignal(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->haltsignal = sig_n;
+
+ return 0;
+}
+
static int config_stopsignal(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
fprintf(fout, "lxc.pts = %d\n", c->pts);
if (c->ttydir)
fprintf(fout, "lxc.devttydir = %s\n", c->ttydir);
+ if (c->haltsignal)
+ fprintf(fout, "lxc.haltsignal = SIG%s\n", sig_name(c->haltsignal));
+ if (c->stopsignal)
+ fprintf(fout, "lxc.stopsignal = SIG%s\n", sig_name(c->stopsignal));
#if HAVE_SYS_PERSONALITY_H
switch(c->personality) {
case PER_LINUX32: fprintf(fout, "lxc.arch = x86\n"); break;
{
bool retv;
pid_t pid;
+ int haltsignal = SIGPWR;
if (!c)
return false;
pid = c->init_pid(c);
if (pid <= 0)
return true;
- kill(pid, SIGPWR);
+ if (c->lxc_conf->haltsignal)
+ haltsignal = c->lxc_conf->haltsignal;
+ kill(pid, haltsignal);
retv = c->wait(c, "STOPPED", timeout);
if (!retv && timeout > 0) {
c->stop(c);
grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config
cat <<EOF >> $path/config
+lxc.haltsignal = SIGUSR1
lxc.utsname = $name
lxc.tty = 1
lxc.pts = 1