From: Stéphane Graber Date: Wed, 22 Jan 2014 18:09:51 +0000 (-0500) Subject: lxc-info: Limit information when not running X-Git-Tag: lxc-1.0.0.beta3~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2177dbc7e095b59f2c5403aeb9e5bd423af19424;p=thirdparty%2Flxc.git lxc-info: Limit information when not running 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 Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c index b51508768..2bd695e7d 100644 --- a/src/lxc/lxc_info.c +++ b/src/lxc/lxc_info.c @@ -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++; + } } } }