February 18th, 2008

  • evan

live restart

Emacs can be modified at runtime because it can just dynamically reexecute new code. But what about a statically {typed,compiled} program?

Since exec() replaces the current process image inline, as long as you serialize in and out externally-perceivable info like which file descriptors are doing what things, you can actually just exec in the new code. It's like restarting, but transparently restarting in-place. (From a mailing list: "With XMonad, you don't lose any windows, layouts, X connections or anything when you persist-and-restart; people have even upgraded several versions and restarted without any problems." [I've never used XMonad.])

Does this really work? I'm trying to think of what other sorts of state you could lose between execs. (An interesting aspect to this is that it's much easier in a language that makes you very explicit when you maintain any in-memory state.)
  • evan

live restart, 2

Just to confirm decklin's suspicions (and mine, too), a post continuing that previous thread:
I looked at xmonad tonight, and unfortunately it doesn't demonstrate a solution to the problem. A window manager like xmonad is just another plain old X11 client, and as such they can disconnect and reconnect to the Xserver without affecting other running X11 clients. When you do alt-Q to reset xmonad, it closes the the connection to the X server, re-execs itself and then opens a new connection to the server. The windows themselves are preserved because they are separate X11 clients, and aren't running "under" xmonad in any sense. The window layout is preserved because xmonad explicitly serializes it, as you can see by running "ps" to see the revised xmonad command line after restarting.
  • evan

xml

I enjoy this modification of a quote: "People that do not understand XML are doomed to make the mistake of using it."