commit 8e2c0ab3d16d7236a42bbc43364086fff65ed927
parent f82f88d1af51c355951fb97b7d4a87b2634ee276
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Mon, 29 Mar 2021 22:31:46 +0200

Fix bug when fgets exits with error

Diffstat:
Mdwmblocks.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dwmblocks.c b/dwmblocks.c @@ -60,7 +60,8 @@ void getcmd(const Block *block, char *output) FILE *cmdf = popen(block->command, "r"); if (!cmdf) return; - fgets(output, CMDLENGTH-strlen(delim), cmdf); + if (fgets(output, CMDLENGTH-strlen(delim), cmdf) == NULL) + output[0] = '\0'; pclose(cmdf); i = strlen(output);