New joyride build 2246

James Cameron quozl at laptop.org
Sun Aug 3 01:45:39 EDT 2008


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 Cameron    mailto:quozl at us.netrek.org     http://quozl.netrek.org/



More information about the Devel mailing list