Commit 2177dbc7 by Stéphane Graber

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: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 7f12cae9
...@@ -301,23 +301,25 @@ static int print_info(const char *name, const char *lxcpath) ...@@ -301,23 +301,25 @@ static int print_info(const char *name, const char *lxcpath)
print_info_msg_str("State:", c->state(c)); print_info_msg_str("State:", c->state(c));
} }
if (pid) { if (c->is_running(c)) {
pid_t initpid; if (pid) {
pid_t initpid;
initpid = c->init_pid(c); initpid = c->init_pid(c);
if (initpid >= 0) if (initpid >= 0)
print_info_msg_int("PID:", initpid); print_info_msg_int("PID:", initpid);
} }
if (ips) { if (ips) {
char **addresses = c->get_ips(c, NULL, NULL, 0); char **addresses = c->get_ips(c, NULL, NULL, 0);
if (addresses) { if (addresses) {
char *address; char *address;
i = 0; i = 0;
while (addresses[i]) { while (addresses[i]) {
address = addresses[i]; address = addresses[i];
print_info_msg_str("IP:", address); print_info_msg_str("IP:", address);
i++; i++;
}
} }
} }
} }
......
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