commit 0972b8a28ab9f0a1211cc9ae70d5684ea95b780d
parent 62ae94ad8d9c4c6a7dc93524d5a3e36d5e537db1
Author: Thuban <thuban@singularity.fr>
Date: Fri, 21 Jun 2013 22:19:22 +0200
Correcting fifo flush
Diffstat:
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/dwm.suckless.org/dwmstatus/fifo.c b/dwm.suckless.org/dwmstatus/fifo.c
@@ -10,7 +10,6 @@
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <errno.h>
#define FIFO "/tmp/dwm.fifo"
@@ -18,26 +17,25 @@ char *
snotif()
{
char buf[BUFSIZ];
- buf[0] = '\0';
+ int len = 0;
- int f = open(FIFO, O_RDONLY | O_NONBLOCK);
+ int f = open(FIFO, O_NONBLOCK | O_RDWR);
if (f == -1){
- perror("fifo opening");
return smprintf("%s","");
}
- if (read(f, buf, sizeof(buf) ) == -1){
+ len = read(f, buf, sizeof(buf));
+ if (len == -1){
perror("fifo read");
return smprintf("%s","");
}
close(f);
- buf[strlen(buf)-1] = '\0';
+ buf[len-1] = '\0';
return smprintf("%s",buf);
}
-
int
main(void)
{