[PATCH] wmacpi: fix musl libc incompatibility in event loop
3 views
Skip to first unread message
david.m...@gmail.com
unread,
Mar 29, 2026, 10:37:08 AM (8 days ago) Mar 29
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Window Maker Development
This patch makes the code to not rely on select() mutating tv, but only uses its return value, as POSIX leaves it unspecified whether select() updates the timeval. glibc historically modifies tv to the remaining timeout while musl follows POSIX strictly and does not touch tv. --- wmacpi/wmacpi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/wmacpi/wmacpi.c b/wmacpi/wmacpi.c index b6ec6c3..bc49fb9 100644 --- a/wmacpi/wmacpi.c +++ b/wmacpi/wmacpi.c @@ -681,6 +681,7 @@ int main(int argc, char **argv) fd_set fds; struct timeval tv_rate; struct timeval tv = {0, 0}; + int select_ret = 0;
DAProgramOption options[] = { {"-r", "--no-scroll", "disable scrolling message", DONone, False, {NULL}}, @@ -894,12 +895,12 @@ int main(int argc, char **argv) * frequently than we sample (most likely). In that case we * set the timeout based on the display update cycle. */
-/* have we completed our timeout, or were we woken up early? */ -if ((tv.tv_sec != 0) || (tv.tv_usec != 0)) +/* Have we completed our timeout, or were we woken up early? + * Use select()'s return value: >0 means a fd became ready (X event), + * 0 means timeout. */ +if (select_ret > 0) goto win_update;