wmsl

Block-based window manager status line
git clone https://git.sinitax.com/sinitax/wmsl
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 905d33fff042b399e005c54dfda48690a9283850
parent 5fb2935eb5b953e3b8a56be301e13f581cadc546
Author: Louis Burda <quent.burda@gmail.com>
Date:   Mon, 18 Jul 2022 21:04:46 +0200

Move constant timeout to variable

Diffstat:
Mwmsl.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/wmsl.c b/wmsl.c @@ -154,6 +154,7 @@ run_block(const char *cmd, pid_t *pid) bool read_block(int fd, char *buf, ssize_t size) { + const uint64_t timeout_ns = 1000000000; struct timeval timeout; struct timespec start, stop; char tmp[256]; @@ -170,8 +171,8 @@ read_block(int fd, char *buf, ssize_t size) FD_ZERO(&fdset); FD_SET(fd, &fdset); - timeout.tv_sec = 0; - timeout.tv_usec = (1000000000 - ns) / 1000; + timeout.tv_sec = (timeout_ns - ns) / 1000000000; + timeout.tv_usec = (timeout_ns - ns) / 1000 % 1000000000; ret = select(fd + 1, &fdset, NULL, NULL, &timeout); @@ -196,7 +197,7 @@ read_block(int fd, char *buf, ssize_t size) nread = read(fd, tmp, sizeof(tmp)); if (nread <= 0) break; } - } while (ns < 1000000000); + } while (ns < timeout_ns); return tok != NULL; }