icewm/icewm-exit-fork.patch

65 lines
2.1 KiB
Diff

Author: Fabian Vogt <fvogt@suse.com>
Subject: Start shutdown and reboot commands in background
When polkit is enabled, systemctl may in turn wait for the
graphical password prompt to return. The created window cannot
be handled by icewm as it is busy with systemctl.
This avoids this deadlock by starting systemctl in background.
---
src/wmmgr.cc | 23 +++++++++++++++++++----
src/wmmgr.h | 1 +
2 files changed, 20 insertions(+), 4 deletions(-)
Index: icewm-1.3.12/src/wmmgr.cc
===================================================================
--- icewm-1.3.12.orig/src/wmmgr.cc
+++ icewm-1.3.12/src/wmmgr.cc
@@ -3011,16 +3011,30 @@ void YWindowManager::updateUserTime(Time
}
}
+void YWindowManager::execAfterFork(const char *command) {
+ pid_t pid = fork();
+ switch(pid) {
+ case -1: /* Failed */
+ warn("fork failed (%d)", errno);
+ return;
+ case 0: /* Child */
+ execl("/bin/sh", "sh", "-c", command, (char *) 0);
+ return; /* Never reached */
+ default: /* Parent */
+ return;
+ }
+}
+
void YWindowManager::checkLogout() {
if (fShuttingDown && !haveClients()) {
+ fShuttingDown = false; /* Only run the command once */
+
if (rebootOrShutdown == 1 && rebootCommand && rebootCommand[0]) {
msg("reboot... (%s)", rebootCommand);
- if (system(rebootCommand) == -1)
- return;
+ execAfterFork(rebootCommand);
} else if (rebootOrShutdown == 2 && shutdownCommand && shutdownCommand[0]) {
msg("shutdown ... (%s)", shutdownCommand);
- if (system(shutdownCommand) == -1)
- return;
+ execAfterFork(shutdownCommand);
} else
app->exit(0);
}
Index: icewm-1.3.12/src/wmmgr.h
===================================================================
--- icewm-1.3.12.orig/src/wmmgr.h
+++ icewm-1.3.12/src/wmmgr.h
@@ -188,6 +188,7 @@ public:
void wmCloseSession();
void exitAfterLastClient(bool shuttingDown);
+ void execAfterFork(const char *command);
void checkLogout();
virtual void resetColormap(bool active);