Skip to content

Commit

Permalink
Added the call to pclose() when the output from the command is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Strahinja committed Nov 18, 2020
1 parent b6b0be4 commit 4c392c3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dwmblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ void getcmd(const Block *block, char *output)
int i = strlen(block->icon);
fgets(output+i, CMDLENGTH-i-delimLen, cmdf);
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;
}
if (delim[0] != '\0') {
//only chop off newline if one is present at the end
i = output[i-1] == '\n' ? i-1 : i;
Expand Down

0 comments on commit 4c392c3

Please sign in to comment.