Re: New joyride build 2246
hello, 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. yours, Bobby On Sun, Aug 3, 2008 at 1:45 AM, James Cameron [EMAIL PROTECTED] wrote: On Sun, Aug 03, 2008 at 12:00:18AM -0400, Michael Stone wrote: If anyone knows how to get rainbow to stop when X dies; please speak up! Yes, up! I've looked at rainbow on 2228 and 2246. I've looked at the process with strace and lsof, and at the source on the XO, and it appears that rainbow has no connection to the X server, but rather one to dbus, ... ... now I don't think there is a notification of X server stop that one can get via dbus, but if someone else knows of one speak up ... ... and you can't XOpenDisplay or initialise Gtk, because the X disconnection handling is a one-time thing, not repeatable ... (I seem to remember we were in this boat with ohm a long time ago?), ... What I've briefly prototyped is a slightly hackish way for the rainbow process to have a method called when the X server stops, as part of a Control/Alt/Backspace, death, or shutdown. Here's a shell equivalent: # telnet 0 6000 || kill `cat /var/run/rainbow.pid` However, I've not finished including it in the rainbow source, because I don't yet understand the gobject event loop. I ran out of time. Here is the technique ... 1. open a TCP connection to port 6000 on 127.0.0.1, or 1. open the UNIX domain X socket, e.g. /tmp/.X11-unix/X0, 2. send no data, 3. receive no data, (discard any data that arrives), 4. include the file descriptor in the poll(2) call made by rainbow, presumably by adding it as an event source to the gobject mainloop in service.py, 5. expect the X server to shutdown the socket when it shuts down, 6. handle the gobject.IO_HUP (a guess) by terminating rainbow. I've not yet tested to my satisfaction how long the X server is willing to maintain a silent TCP connection. So far the answer seems to be forever. Another alternative might be to take the connection management parts of python-xlib, and reduce them down. There doesn't seem to be any keep alive or timeout stuff in it. -- James Cameronmailto:[EMAIL PROTECTED] http://quozl.netrek.org/ ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: New joyride build 2246
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 Cameronmailto:[EMAIL PROTECTED] http://quozl.netrek.org/ ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: New joyride build 2246
On Sat, Aug 02, 2008 at 11:50:59PM -0400, Build Announcer v2 wrote: http://xs-dev.laptop.org/~cscott/olpc/streams/joyride/build2246 Changes in build 2246 from build: 2245 Size delta: 0.00M -rainbow 0.7.17-1.fc9 +rainbow 0.7.18-1.fc9 This build partially resolves the original #6797 issue but is subject to a resource leak due to me and Bobby present lack of comprehension of upstart's expectations on processes that it launches. If anyone knows how to get rainbow to stop when X dies; please speak up! Michael ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: New joyride build 2246
On Sun, Aug 03, 2008 at 12:00:18AM -0400, Michael Stone wrote: If anyone knows how to get rainbow to stop when X dies; please speak up! Yes, up! I've looked at rainbow on 2228 and 2246. I've looked at the process with strace and lsof, and at the source on the XO, and it appears that rainbow has no connection to the X server, but rather one to dbus, ... ... now I don't think there is a notification of X server stop that one can get via dbus, but if someone else knows of one speak up ... ... and you can't XOpenDisplay or initialise Gtk, because the X disconnection handling is a one-time thing, not repeatable ... (I seem to remember we were in this boat with ohm a long time ago?), ... What I've briefly prototyped is a slightly hackish way for the rainbow process to have a method called when the X server stops, as part of a Control/Alt/Backspace, death, or shutdown. Here's a shell equivalent: # telnet 0 6000 || kill `cat /var/run/rainbow.pid` However, I've not finished including it in the rainbow source, because I don't yet understand the gobject event loop. I ran out of time. Here is the technique ... 1. open a TCP connection to port 6000 on 127.0.0.1, or 1. open the UNIX domain X socket, e.g. /tmp/.X11-unix/X0, 2. send no data, 3. receive no data, (discard any data that arrives), 4. include the file descriptor in the poll(2) call made by rainbow, presumably by adding it as an event source to the gobject mainloop in service.py, 5. expect the X server to shutdown the socket when it shuts down, 6. handle the gobject.IO_HUP (a guess) by terminating rainbow. I've not yet tested to my satisfaction how long the X server is willing to maintain a silent TCP connection. So far the answer seems to be forever. Another alternative might be to take the connection management parts of python-xlib, and reduce them down. There doesn't seem to be any keep alive or timeout stuff in it. -- James Cameronmailto:[EMAIL PROTECTED] http://quozl.netrek.org/ ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel