From 6890a27a3a4b0ac5f57d1fe554db0dbb90909072 Mon Sep 17 00:00:00 2001 From: Aaron Marcher Date: Mon, 10 Oct 2016 09:19:44 +0200 Subject: fixed run_command() --- slstatus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'slstatus.c') diff --git a/slstatus.c b/slstatus.c index 9272c54..57ef9a9 100644 --- a/slstatus.c +++ b/slstatus.c @@ -400,7 +400,7 @@ static char * run_command(const char *cmd) { FILE *fp; - char buf[64] = "n/a"; + char buf[1024] = "n/a"; fp = popen(cmd, "r"); if (fp == NULL) { @@ -408,9 +408,11 @@ run_command(const char *cmd) return smprintf(UNKNOWN_STR); } fgets(buf, sizeof(buf)-1, fp); - buf[strlen(buf)-1] = '\0'; pclose(fp); + buf[strlen(buf)] = '\0'; + strtok(buf, "\n"); + return smprintf("%s", buf); } -- cgit v1.2.3