Merge pull request #39 from Strahinja/master

Add the call to pclose() when the output from the block command is empty
This commit is contained in:
torrinfail 2020-12-24 16:53:26 -07:00 committed by GitHub
commit 0e22e81b1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -65,8 +65,11 @@ void getcmd(const Block *block, char *output)
int i = strlen(block->icon); int i = strlen(block->icon);
fgets(output+i, CMDLENGTH-i-delimLen, cmdf); fgets(output+i, CMDLENGTH-i-delimLen, cmdf);
i = strlen(output); i = strlen(output);
if (i == 0)//return if block and command output are both empty if (i == 0) {
//return if block and command output are both empty
pclose(cmdf);
return; return;
}
if (delim[0] != '\0') { if (delim[0] != '\0') {
//only chop off newline if one is present at the end //only chop off newline if one is present at the end
i = output[i-1] == '\n' ? i-1 : i; i = output[i-1] == '\n' ? i-1 : i;