I've been sporadically experiencing the symptoms of Bugs 720362, 1070663, 1022781 and was poking at it. I now believe that they all might have the same root cause as this bug.
I doubt I would have figured this out if it wasn't for Frédéric noting that some programs trigger "xdg-screensaver reset" and that triggers "xautolock -restart". So thats why I'm attaching everything to this bug. Thank you very much Frédéric. The -restart option is broken for two reasons: 1. The -restart uses execv() which depends on xautolock having been started with the full path to the binary. If you start it without the full path, then execv() fails. So the first patch I've attached switches xautolock to execvp() so that it does a PATH lookup. 2. After fixing that, xautolock was able to re-exec itself but it immediately terminated. The second problem turned out to be that xautolock is closing stdout and stderr instead of redirecting them to /dev/null. This means that the next file desctiptor opened by xautolock becomes stdout. xautolock seems mostly okay with this because it doesn't open any new file descriptors after closing stdout/stderr... unless it restart itself. At some point during program startup, something unexpected gets a hold of the file descriptor for stdout and/or stderr and the program terminates. So the second patch changes the code to use freopen() with /dev/null. With these two patches applied, the -restart option is working for me. My copy of mpv doesn't seem to trigger xdg-screensaver, but VLC does and I know I ran VLC yesterday at some point before the bug showed up. -- Jon Doge Wrangler X(7): A program for managing terminal windows. See also screen(1) and tmux(1).
Description: Fix usage of execv() When the -restart options is used, xautolock restarts itself with the execv() function. This only works if xautolock was started using its full path. Switching to execvp() allows restarts to work even when xautolock wasn't started with the full path. Author: Jon DeVree <n...@vault24.org> Bug-Debian: https://bugs.debian.org/855658 --- xautolock-2.2.orig/src/message.c +++ xautolock-2.2/src/message.c @@ -104,7 +104,7 @@ restartByMessage (Display* d, Window roo { XDeleteProperty (d, root, semaphore); XFlush (d); - execv (argArray[0], argArray); + execvp (argArray[0], argArray); } }
Description: Fix the usage of fclose When restarting, xautolock (like most programs) expects the first 3 file descriptors to be stdin, stdout, and stderr. Because xautolock was closing the file descriptors instead of redirecting them to /dev/null, this caused the program to crash upon restart. Switching the calls to freopen() fixes this. Author: Jon DeVree <n...@vault24.org> Bug-Debian: https://bugs.debian.org/855658 --- The information above should follow the Patch Tagging Guidelines, please checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>) Bug: <upstream-bugtracker-url> Bug-Debian: https://bugs.debian.org/<bugnumber> Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> Forwarded: (no|not-needed|<patch-forwarded-url>) Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>) Reviewed-By: <name and email of someone who approved/reviewed the patch> Last-Update: 2025-01-12 --- xautolock-2.2.orig/src/xautolock.c +++ xautolock-2.2/src/xautolock.c @@ -119,8 +119,8 @@ main (int argc, char* argv[]) checkConnectionAndSendMessage (d); resetTriggers (); - if (!noCloseOut) (void) fclose (stdout); - if (!noCloseErr) (void) fclose (stderr); + if (!noCloseOut) (void) freopen ("/dev/null", "w", stdout); + if (!noCloseErr) (void) freopen ("/dev/null", "w", stderr); #ifdef HasXidle queryExtension (Xidle, useXidle)