summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAuke Kok <auke-jan.h.kok@intel.com>2012-08-23 16:31:39 -0700
committerAuke Kok <auke-jan.h.kok@intel.com>2012-08-23 16:31:39 -0700
commit54996371103c6965f89fb309036cb3959813c05d (patch)
tree4d773a1566804c7a39a21bd3196a0b203f064662
parenta544269448c37babe135e67586ad4fe40c96c87d (diff)
downloadxorg-launch-helper-54996371103c6965f89fb309036cb3959813c05d.tar.gz
xorg-launch-helper-54996371103c6965f89fb309036cb3959813c05d.tar.bz2
xorg-launch-helper-54996371103c6965f89fb309036cb3959813c05d.zip
Attempt to fix shutdown issue causing 90sec timeout.
This adds a PIDFile for Xorg in the XDG_RUNTIME_DIR, in an attempt to fix the shutdown timeout. The theory is that with this PIDFile, system --user knows how to properly shut down Xorg, and won't wait for 90 seconds to see it exit. However, it doesn't work. I still see timeouts when shutting down with this patch.
-rw-r--r--src/main.c20
-rw-r--r--xorg.service.in1
2 files changed, 20 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 4f996b2..0475007 100644
--- a/src/main.c
+++ b/src/main.c
@@ -74,8 +74,11 @@ int main(int argc, char **argv)
ret = fork();
if (ret) {
struct timespec tv;
+ char *xdg;
+ char pidfile[PATH_MAX];
+ FILE *fp;
- fprintf(stderr, "Started Xorg[%d]", ret);
+ fprintf(stderr, "Started Xorg[%d]\n", ret);
/* setup sighandler for main thread */
clock_gettime(CLOCK_REALTIME, &tv);
@@ -85,6 +88,21 @@ int main(int argc, char **argv)
pthread_cond_timedwait(&notify_condition, &notify_mutex, &tv);
pthread_mutex_unlock(&notify_mutex);
+ xdg = getenv("XDG_RUNTIME_DIR");
+ if (!xdg) {
+ fprintf(stderr, "Unable to create pidfile: XDG_RUNTIME_DIR is not set.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ snprintf(pidfile, PATH_MAX, "%s/Xorg.pid", xdg);
+ fp = fopen(pidfile, "w");
+ if (!fp) {
+ fprintf(stderr, "Unable to write pidfile.\n");
+ exit(EXIT_FAILURE);
+ }
+ fprintf(fp, "%d\n", ret);
+ fclose(fp);
+
//FIXME - return an error code if timer expired instead.
exit(EXIT_SUCCESS);
}
diff --git a/xorg.service.in b/xorg.service.in
index 36019f0..8ba953b 100644
--- a/xorg.service.in
+++ b/xorg.service.in
@@ -18,6 +18,7 @@ Before=xorg.target
[Service]
Type=forking
ExecStart=@prefix@/bin/xorg-launch-helper
+PIDFile=%t/Xorg.pid
Restart=always
RestartSec=10