os: add support for systemd notification
It can take some time for Xorg to start. If Xorg runs as a systemd service and other services are based on it, they have no way to determine when Xorg is really ready to accept requests. Let's use sd_notify() provided by libsystemd to signal systemd for readiness. If Xorg has not been started as a systemd service, this won't do anything. Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
This commit is contained in:
parent
9d25408a59
commit
bb46e78540
|
@ -54,7 +54,8 @@ The X server may also be started directly by the user, though this
|
||||||
method is usually reserved for testing and is not recommended for
|
method is usually reserved for testing and is not recommended for
|
||||||
normal operation. On some platforms, the user must have special
|
normal operation. On some platforms, the user must have special
|
||||||
permission to start the X server, often because access to certain
|
permission to start the X server, often because access to certain
|
||||||
devices (e.g. \fI/dev/mouse\fP) is restricted.
|
devices (e.g. \fI/dev/mouse\fP) is restricted. Where applicable, the
|
||||||
|
X server notifies systemd when it is ready to process requests.
|
||||||
.PP
|
.PP
|
||||||
When the X server starts up, it typically takes over the display. If
|
When the X server starts up, it typically takes over the display. If
|
||||||
you are running on a workstation whose console is the display, you may
|
you are running on a workstation whose console is the display, you may
|
||||||
|
|
|
@ -116,6 +116,10 @@ SOFTWARE.
|
||||||
#define zoneid_t int
|
#define zoneid_t int
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYSTEMD_DAEMON
|
||||||
|
#include <systemd/sd-daemon.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "probes.h"
|
#include "probes.h"
|
||||||
|
|
||||||
struct ospoll *server_poll;
|
struct ospoll *server_poll;
|
||||||
|
@ -207,6 +211,11 @@ NotifyParentProcess(void)
|
||||||
}
|
}
|
||||||
if (RunFromSigStopParent)
|
if (RunFromSigStopParent)
|
||||||
raise(SIGSTOP);
|
raise(SIGSTOP);
|
||||||
|
#ifdef HAVE_SYSTEMD_DAEMON
|
||||||
|
/* If we have been started as a systemd service, tell systemd that
|
||||||
|
we are ready. Otherwise sd_notify() won't do anything. */
|
||||||
|
sd_notify(0, "READY=1");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user