From 4ab9cb7fcc83498a19f1c554ce45d62a3ee15e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 30 Jul 2015 12:20:41 +0200 Subject: [PATCH] Fix display of status flags in session list --- abduco.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/abduco.c b/abduco.c index cf1a860..0222d26 100644 --- a/abduco.c +++ b/abduco.c @@ -546,25 +546,14 @@ static int list_session(void) { char status = ' '; char *local = strstr(namelist[n]->d_name, server.host); if (local) { - char *name = strdup(namelist[n]->d_name); *local = '\0'; /* truncate hostname if we are local */ - if (session_alive(namelist[n]->d_name)) - status = '*'; - else if (session_exists(namelist[n]->d_name)) - status = '+'; - /* check if the socket is still valid, session_{alive,exists} - * might have deleted it */ - if (name && stat(name, &sb) == -1) { - free(name); + if (!session_exists(namelist[n]->d_name)) continue; - } - free(name); - } else { - if (sb.st_mode & S_IXUSR) - status = '*'; - else if (sb.st_mode & S_IXGRP) - status = '+'; } + if (sb.st_mode & S_IXUSR) + status = '*'; + else if (sb.st_mode & S_IXGRP) + status = '+'; printf("%c %s\t%s\n", status, buf, namelist[n]->d_name); } free(namelist[n]);