diff options
author | raiz <raiz@firemail.cc> | 2016-12-27 18:57:27 +0300 |
---|---|---|
committer | raiz <raiz@firemail.cc> | 2016-12-27 18:57:27 +0300 |
commit | b7f4541506aac11a92d947939f6e9da8af49dd26 (patch) | |
tree | 268f14e8431c3a2f35c078b794e5f01c3950ce61 /slstatus.c | |
parent | 3bfc3bbcae41c58cc527ee074468afc83ef1a9ab (diff) |
remove newline character from run_command() output accurately
Diffstat (limited to 'slstatus.c')
-rw-r--r-- | slstatus.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -405,6 +405,7 @@ ram_used(void) static char * run_command(const char *cmd) { + char *nlptr; FILE *fp; char buf[1024] = "n/a"; @@ -415,9 +416,12 @@ run_command(const char *cmd) } fgets(buf, sizeof(buf), fp); pclose(fp); - buf[strlen(buf)] = '\0'; + if ((nlptr = strstr(buf, "\n")) != NULL) { + nlptr[0] = '\0'; + } + return smprintf("%s", buf); } |