You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
3.0 KiB

From 82d71c1371dd15acd04088bd1a1b9827bb461765 Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Wed, 31 Aug 2022 16:11:34 +0900
Subject: [PATCH] watchdog_timer: don't relaunch hacks when unblanking
Currently, when gfx receives SIGTERM and then executing xt_sigterm_handler,
after killing remaining hacks by kill_screenhack, sometimes watchdog_timer
seems called and hacks are relauched. These hacks remains unkilled even after
the parent gfx dies (immediately), and they becomes children of init, no
longer handled by xscreensaver side.
As a workaround, when gfx receives SIGTERM and is going to die, mark so
in saver_info struct data, and watchdog_timer checks saver_info data and
will not going to relaunch hacks when seeing the mark.
---
driver/subprocs.c | 4 ++++
driver/types.h | 1 +
driver/windows.c | 10 +++++++++-
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/driver/subprocs.c b/driver/subprocs.c
index 6e522d3..9cef60c 100644
--- a/driver/subprocs.c
+++ b/driver/subprocs.c
@@ -461,6 +461,10 @@ xt_sigterm_handler (XtPointer data, XtSignalId *id)
fprintf (stderr, "%s: %s: unblanking\n", blurb(),
signal_name (sigterm_received));
+ /* mark this process now terminating, so that watchdog_time won't
+ relaunch hacks with race condition */
+ si->terminating_p = True;
+
/* Kill before unblanking, to stop drawing as soon as possible. */
for (i = 0; i < si->nscreens; i++)
{
diff --git a/driver/types.h b/driver/types.h
index 8fa7c8e..cee25fe 100644
--- a/driver/types.h
+++ b/driver/types.h
@@ -146,6 +146,7 @@ struct saver_info {
been received; set to N if SELECT or DEMO N
has been received. (This is kind of nasty.)
*/
+ Bool terminating_p; /* Whether the saver (gfx) is now terminating or not */
};
diff --git a/driver/windows.c b/driver/windows.c
index c92486a..b6576cc 100644
--- a/driver/windows.c
+++ b/driver/windows.c
@@ -959,7 +959,7 @@ watchdog_timer (XtPointer closure, XtIntervalId *id)
{
saver_info *si = (saver_info *) closure;
saver_preferences *p = &si->prefs;
- Bool running_p, on_p;
+ Bool running_p, on_p, terminating_p;
/* If the DPMS settings on the server have changed, change them back to
what ~/.xscreensaver says they should be. */
@@ -972,6 +972,7 @@ watchdog_timer (XtPointer closure, XtIntervalId *id)
running_p = any_screenhacks_running_p (si);
on_p = monitor_powered_on_p (si->dpy);
+ terminating_p = si->terminating_p;
if (running_p && !on_p)
{
int i;
@@ -983,6 +984,13 @@ watchdog_timer (XtPointer closure, XtIntervalId *id)
kill_screenhack (&si->screens[i]);
/* Do not clear current_hack here. */
}
+ else if (terminating_p)
+ {
+ /* Server (gfx) is now terminating (with unblanking screen).
+ killing remaining hacks should have done beforehand.
+ Don't do anything here.
+ */
+ }
else if (!running_p && on_p)
{
/* If the hack number is set but no hack is running, it is because the
--
2.37.2