]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-monitord: exit when got a quit command 1662/head
author0x0916 <w@laoqinren.net>
Sat, 1 Jul 2017 06:04:14 +0000 (14:04 +0800)
committer0x0916 <w@laoqinren.net>
Sat, 1 Jul 2017 06:06:00 +0000 (14:06 +0800)
lxc-monitor has an option to tell lxc-monitord to quit.

```
~/lxc (master) # lxc-monitor --help
lxc-monitor monitors the state of the NAME container

Options :
  -n, --name=NAME   NAME of the container
                    NAME may be a regular expression
  -Q, --quit        tell lxc-monitord to quit
```
But it does not work. This patch fix that.

Signed-off-by: 0x0916 <w@laoqinren.net>
src/lxc/lxc_monitord.c

index 456c4fc947f4089f84ff7c5f091d07d869d35933..c4c2ba0d1d9c5dd501306f89b48970c330c96105 100644 (file)
@@ -430,10 +430,18 @@ int main(int argc, char *argv[])
               getpid(), mon.lxcpath);
        for (;;) {
                ret = lxc_mainloop(&mon.descr, 1000 * 30);
+               if (ret) {
+                       ERROR("mainloop returned an error");
+                       break;
+               }
                if (mon.clientfds_cnt <= 0) {
                        NOTICE("No remaining clients. lxc-monitord is exiting.");
                        break;
                }
+               if (quit == 1) {
+                       NOTICE("got quit command. lxc-monitord is exitting.");
+                       break;
+               }
        }
 
 on_signal: