aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorAdam Jackson <ajax@nwnk.net>2017-03-15 12:08:46 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-03-21 10:58:08 +0100
commitf5301dee4e400698f5b8ea324686b8daba75152d (patch)
tree979150a94645046d512c3f7e87aebd5353795b67 /nx-X11
parent4f76ed19b8a7b9448e29ac152f7f5ec1e611950e (diff)
downloadnx-libs-f5301dee4e400698f5b8ea324686b8daba75152d.tar.gz
nx-libs-f5301dee4e400698f5b8ea324686b8daba75152d.tar.bz2
nx-libs-f5301dee4e400698f5b8ea324686b8daba75152d.zip
Move SIGUSR1 notification as late as possible.
commit f01e149d1af14ef9ee0e8a6743ab6a08f3bb677c Author: Adam Jackson <ajax@redhat.com> Date: Thu Nov 1 15:41:11 2007 -0400 Move SIGUSR1 notification as late as possible. If we inherited a signal mask from the parent process that ignores SIGUSR1, then we will send SIGUSR1 to the parent to indicate when we're ready to accept connections. Unfortunately, we send this notification way too early, right after creating the sockets rather than just before entering the main loop. Move it to just before Dispatch() so we're not lying quite so much. Backported-to-NX-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/programs/Xserver/dix/main.c2
-rw-r--r--nx-X11/programs/Xserver/include/os.h2
-rw-r--r--nx-X11/programs/Xserver/os/connection.c87
3 files changed, 53 insertions, 38 deletions
diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c
index 50bbeb3dc..72ed40108 100644
--- a/nx-X11/programs/Xserver/dix/main.c
+++ b/nx-X11/programs/Xserver/dix/main.c
@@ -432,6 +432,8 @@ main(int argc, char *argv[], char *envp[])
FatalError("could not create connection block info");
}
+ NotifyParentProcess();
+
Dispatch();
/* Now free up whatever must be freed */
diff --git a/nx-X11/programs/Xserver/include/os.h b/nx-X11/programs/Xserver/include/os.h
index 5de8463e7..5dd5e2012 100644
--- a/nx-X11/programs/Xserver/include/os.h
+++ b/nx-X11/programs/Xserver/include/os.h
@@ -120,6 +120,8 @@ extern void ResetOsBuffers(void);
extern void InitConnectionLimits(void);
+extern void NotifyParentProcess(void);
+
extern void CreateWellKnownSockets(void);
extern void ResetWellKnownSockets(void);
diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c
index d4627e97c..172ed6f4c 100644
--- a/nx-X11/programs/Xserver/os/connection.c
+++ b/nx-X11/programs/Xserver/os/connection.c
@@ -319,6 +319,52 @@ InitConnectionLimits(void)
#endif
}
+/*
+ * If SIGUSR1 was set to SIG_IGN when the server started, assume that either
+ *
+ * a- The parent process is ignoring SIGUSR1
+ *
+ * or
+ *
+ * b- The parent process is expecting a SIGUSR1
+ * when the server is ready to accept connections
+ *
+ * In the first case, the signal will be harmless, in the second case,
+ * the signal will be quite useful.
+ */
+static void
+InitParentProcess(void)
+{
+#if !defined(WIN32)
+ OsSigHandlerPtr handler;
+ handler = OsSignal (SIGUSR1, SIG_IGN);
+ if ( handler == SIG_IGN)
+ RunFromSmartParent = TRUE;
+ OsSignal(SIGUSR1, handler);
+ ParentProcess = getppid ();
+#ifdef __UNIXOS2__
+ /*
+ * fg030505: under OS/2, xinit is not the parent process but
+ * the "grant parent" process of the server because execvpe()
+ * presents us an additional process number;
+ * GetPPID(pid) is part of libemxfix
+ */
+ ParentProcess = GetPPID (ParentProcess);
+#endif /* __UNIXOS2__ */
+#endif
+}
+
+void
+NotifyParentProcess(void)
+{
+#if !defined(WIN32)
+ if (RunFromSmartParent) {
+ if (ParentProcess > 1) {
+ kill (ParentProcess, SIGUSR1);
+ }
+ }
+#endif
+}
/*****************
* CreateWellKnownSockets
@@ -331,7 +377,6 @@ CreateWellKnownSockets(void)
int i;
int partial;
char port[20];
- OsSigHandlerPtr handler;
FD_ZERO(&AllSockets);
FD_ZERO(&AllClients);
@@ -385,33 +430,9 @@ CreateWellKnownSockets(void)
OsSignal (SIGTERM, GiveUp);
XFD_COPYSET (&WellKnownConnections, &AllSockets);
ResetHosts(display);
- /*
- * Magic: If SIGUSR1 was set to SIG_IGN when
- * the server started, assume that either
- *
- * a- The parent process is ignoring SIGUSR1
- *
- * or
- *
- * b- The parent process is expecting a SIGUSR1
- * when the server is ready to accept connections
- *
- * In the first case, the signal will be harmless,
- * in the second case, the signal will be quite
- * useful
- */
-#if !defined(WIN32)
- handler = OsSignal (SIGUSR1, SIG_IGN);
- if ( handler == SIG_IGN)
- RunFromSmartParent = TRUE;
- OsSignal(SIGUSR1, handler);
- ParentProcess = getppid ();
- if (RunFromSmartParent) {
- if (ParentProcess > 1) {
- kill (ParentProcess, SIGUSR1);
- }
- }
-#endif
+
+ InitParentProcess();
+
#ifdef XDMCP
XdmcpInit ();
#endif
@@ -500,16 +521,6 @@ ResetWellKnownSockets (void)
ResetAuthorization ();
ResetHosts(display);
/*
- * See above in CreateWellKnownSockets about SIGUSR1
- */
-#if !defined(WIN32)
- if (RunFromSmartParent) {
- if (ParentProcess > 1) {
- kill (ParentProcess, SIGUSR1);
- }
- }
-#endif
- /*
* restart XDMCP
*/
#ifdef XDMCP