New joyride build 2246

James Cameron quozl at laptop.org
Sun Aug 3 03:23:43 EDT 2008


On Sun, Aug 03, 2008 at 02:50:51AM -0400, Bobby Powers wrote:
> I believe this is the type of stuff Upstart was designed for, and my
> limited testing shows that adding the line
> stop on stopping prefdm
> 
> to the rainbow upstart job sufficiently links rainbow with X.

Excellent.  Much shorter and simpler than my yet to be tested hack, so
I'll leave it where it got up to:

diff --git a/rainbow/rainbow/service.py b/rainbow/rainbow/service.py
index d292dfc..d20e8b3 100644
--- a/rainbow/rainbow/service.py
+++ b/rainbow/rainbow/service.py
@@ -1,4 +1,5 @@
 import os
+import socket
 from signal import SIGCHLD
 from time import time
 
@@ -137,6 +138,23 @@ class Rainbow(dbus.service.Object):
             util.trace()
             error_cont(e)
 
+def x_hup(source, condition):
+    log("X socket hangup")
+    os._exit(1)
+
+def x_in(source, condition):
+    data = source.recv(12)
+    if len(data) > 0:
+        return True
+    log("X socket closure")
+    os._exit(1)
+
+def x_watch():
+    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    sock.connect(('127.0.0.1', 6000))
+    gobject.io_add_watch(sock, gobject.IO_HUP, x_hup)
+    gobject.io_add_watch(sock, gobject.IO_IN, x_in)
+
 def run(opts, args):
     """Start the Rainbow DBus service."""
     log("GC'ing spool %s", SPOOL)
@@ -155,4 +173,5 @@ def run(opts, args):
 
     print 'Service running mainloop.'
     mainloop = gobject.MainLoop()
+    x_watch()
     mainloop.run()

-- 
James Cameron    mailto:quozl at us.netrek.org     http://quozl.netrek.org/



More information about the Devel mailing list