Index | Thread | Search

From:
Laurence Tratt <laurie@tratt.net>
Subject:
Unbreak DEBUG for xidle
To:
tech@openbsd.org
Date:
Mon, 16 Jun 2025 08:32:38 +0100

Download raw body.

Thread
  • Laurence Tratt:

    Unbreak DEBUG for xidle

While trying (unsuccessfully [1]) to work out why on recent snapshots X
events don't seem to be working for xidle on my amd64 machine, I enabled
its DEBUG mode... and it didn't produce any output. It turns out that
xidle always redirects stdout and stderr to `/dev/null`. The simple diff
at the end of this email suppresses that when `DEBUG` is set.


Laurie

[1] https://marc.info/?l=openbsd-bugs&m=174981856611113&w=2


diff --git app/xidle/xidle.c app/xidle/xidle.c
index 623ca784a..c302d710a 100644
--- app/xidle/xidle.c
+++ app/xidle/xidle.c
@@ -327,7 +331,9 @@ main(int argc, char **argv)
 	char *args[10];
 	int area = 2, delay = 2, timeout = 0;
 	int position = north|west;
+#ifndef DEBUG
 	int fd;
+#endif
 	u_long last_serial = 0;
 
 	parse_opts(argc, argv, &x.dpy, &area, &delay, &timeout,
@@ -345,6 +351,7 @@ main(int argc, char **argv)
 	signal(SIGTERM, handler);
 	signal(SIGUSR1, handler);
 
+#ifndef DEBUG
 	fd = open(_PATH_DEVNULL, O_RDWR);
 	if (fd < 0)
 		err(1, _PATH_DEVNULL);
@@ -353,6 +360,7 @@ main(int argc, char **argv)
 	dup2(fd, STDERR_FILENO);
 	if (fd > 2)
 		close(fd);
+#endif
 
 	if (pledge("stdio proc exec", NULL) == -1)
 		err(1, "pledge");