]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-info: Limit information when not running
authorStéphane Graber <stgraber@ubuntu.com>
Wed, 22 Jan 2014 18:09:51 +0000 (13:09 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 22 Jan 2014 18:38:50 +0000 (13:38 -0500)
Don't try to print the PID, IP addresses or statistics for a container
that's not current running.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc_info.c

index b515087686e955209f3d6a0a5c073968d72c301d..2bd695e7d9ba903e28da4888b118925ae0c4d89b 100644 (file)
@@ -301,23 +301,25 @@ static int print_info(const char *name, const char *lxcpath)
                print_info_msg_str("State:", c->state(c));
        }
 
-       if (pid) {
-               pid_t initpid;
+       if (c->is_running(c)) {
+               if (pid) {
+                       pid_t initpid;
 
-               initpid = c->init_pid(c);
-               if (initpid >= 0)
-                       print_info_msg_int("PID:", initpid);
-       }
+                       initpid = c->init_pid(c);
+                       if (initpid >= 0)
+                               print_info_msg_int("PID:", initpid);
+               }
 
-       if (ips) {
-               char **addresses = c->get_ips(c, NULL, NULL, 0);
-               if (addresses) {
-                       char *address;
-                       i = 0;
-                       while (addresses[i]) {
-                               address = addresses[i];
-                               print_info_msg_str("IP:", address);
-                               i++;
+               if (ips) {
+                       char **addresses = c->get_ips(c, NULL, NULL, 0);
+                       if (addresses) {
+                               char *address;
+                               i = 0;
+                               while (addresses[i]) {
+                                       address = addresses[i];
+                                       print_info_msg_str("IP:", address);
+                                       i++;
+                               }
                        }
                }
        }