mirror of
https://github.com/pikami/slstatus.git
synced 2024-11-27 22:05:42 +00:00
remove newline character from run_command() output accurately
This commit is contained in:
parent
3bfc3bbcae
commit
b7f4541506
@ -405,6 +405,7 @@ ram_used(void)
|
|||||||
static char *
|
static char *
|
||||||
run_command(const char *cmd)
|
run_command(const char *cmd)
|
||||||
{
|
{
|
||||||
|
char *nlptr;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[1024] = "n/a";
|
char buf[1024] = "n/a";
|
||||||
|
|
||||||
@ -415,9 +416,12 @@ run_command(const char *cmd)
|
|||||||
}
|
}
|
||||||
fgets(buf, sizeof(buf), fp);
|
fgets(buf, sizeof(buf), fp);
|
||||||
pclose(fp);
|
pclose(fp);
|
||||||
|
|
||||||
buf[strlen(buf)] = '\0';
|
buf[strlen(buf)] = '\0';
|
||||||
|
|
||||||
|
if ((nlptr = strstr(buf, "\n")) != NULL) {
|
||||||
|
nlptr[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
return smprintf("%s", buf);
|
return smprintf("%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user