[PATCH] Let X tell us when it's launched rather than just sleeping.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



X will send us SIGUSR1 when it's ready to accept connections.
---
 anaconda |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/anaconda b/anaconda
index 2731c43..86d2205 100755
--- a/anaconda
+++ b/anaconda
@@ -832,11 +832,33 @@ if __name__ == "__main__":
     # running on a redirected X display, so start local X server
     if opts.display_mode == 'g' and not os.environ.has_key('DISPLAY') and not flags.usevnc:
         try:
+	    # start X with its USR1 handler set to ignore.  this will make it send
+	    # us SIGUSR1 if it succeeds.  if it fails, catch SIGCHLD and bomb out.
+
+	    def sigchld_handler(num, frame):
+		raise OSError
+
+	    def sigusr1_handler(num, frame):
+		pass
+
+	    def preexec_fn():
+		signal.signal(signal.SIGUSR1, signal.SIG_IGN)
+
             xout = open("/dev/tty5", "w")
-            proc = subprocess.Popen(["Xorg", "-br", "-logfile", "/tmp/X.log", ":1", "vt6", "-s", "1440", "-ac", "-nolisten", "tcp", "-dpi", "96"], close_fds=True, stdout=xout, stderr=xout)
-            time.sleep(5)
-            if proc.poll() is not None:
-                raise OSError
+	    old_sigusr1 = signal.signal(signal.SIGUSR1, sigusr1_handler)
+	    old_sigchld = signal.signal(signal.SIGCHLD, sigchld_handler)
+
+            proc = subprocess.Popen(["Xorg", "-br", "-logfile", "/tmp/X.log",
+				     ":1", "vt6", "-s", "1440", "-ac",
+				     "-nolisten", "tcp", "-dpi", "96"],
+				     close_fds=True, stdout=xout, stderr=xout,
+				     preexec_fn=preexec_fn)
+
+	    signal.pause()
+
+	    signal.signal(signal.SIGUSR1, old_sigusr1)
+	    signal.signal(signal.SIGCHLD, old_sigchld)
+
             os.environ["DISPLAY"] = ":1"
             doStartupX11Actions(opts.runres)
             xserver_pid = proc.pid
-- 
1.6.0.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux