Reviving a stuck X11 server while keeping GUI apps running

2

I've been running one X server for a several days. Today, due to some transient glitch, it's hung up. The multitude of X applications - text editors, web browser, graphics apps, etc - are still running and are probably fine. The X server seems to have gone bad.

I can start a new x server in another virtual terminal - ctrl-alt-F1, ctrl-alt-F2, etc. The original dead one is on ctrl-alt-F1, and would report DISPLAY=:0 if it could do anything. I started new ones on ctrl-alt-F2 where DISPLAY=:1 and ctrl-alt-F3 where DISPLAY=:2.

Until this event today, I didn't know Linux could run more than one X server at a time, and have them associated with vterms like this. Before, it was always F7 that had the X server, or F5 many years ago. I'm using Arch Linux, installed fresh about a month ago. I don't keep up with X11 or Linux news much.

QUESTION: the original F1 server is showing only black screen with a cursor. The cursor moves. But the apps, which show up in "ps aux" and give other signs of life beside their GUI, I'm sure are still running.

QUESTION: is there some way to give the F1 X11 server a kick, to wake it up, get it unstuck, restart it, get it working again? Without losing the exising GUI processes of course.

If not, the my next question is how to move a running process such as GIMP, Kwrite, etc. from appearing on the DISPLAY=:0 X server to become fully present and functional on the :2 server. But that is a separate question, and has been asked elsewhere. Before I try to monkey with that, though, I'd like to see if I can revive the original X server.

DarenW

Posted 2014-06-03T03:33:34.090

Reputation: 1 707

Answers

3

If your X server is stuck, there's nothing much you can do. Your only bet is to kill applications hoping the one that made it freeze (like a 3D game stuck in an infinite loop hogging the server) releases the resources and it starts working again. It might be the compositing manager too if you use one so you can kill it and restart it and see if it helps (most modern DEs do, and if you use Gnome killing the shell will kill your whole session). However, odds are more that the server is just unrecoverable unless you want to dig deep into it with gdb (you wouldn't be asking here if you were able to).

Moving to the next question, I'm pretty sure it is not possible to move applications from an X server to another either:

  • GUI applications usually have more than just the connection to the X server. They may have multiple other resources attached to them, including some tied to the graphics card. For example: OpenGL contexts. You are attempting to move an app from two local servers, but X11 is actually a network protocol. The destination X server could as well be on the opposite side of the globe with different hardware and everything.

  • Most applications do not plan for losing the connection to the X server. I have yet to find any application that even handles a lost connection to the server: most apps just crash instead.

  • Moving an application from an X server to another would break many assumptions applications make on start, particularly about what's available to them (OpenGL versions, X version, extensions). Handling all those edge cases are just not worth the hassle.

  • Xorg is just not expected to crash, in the same way apps are not expecting the kernel to die or break itself.

There are in fact ways to move windows from one X server to another one, but it involves using an X11 proxy like Xdmx. It's the only one I could find, not updated since 2004 and has a few issues. I wouldn't count on that for real work.

Just killing Xorg and restarting is probably your best solution. Just remember to save your work frequently!

Max-P

Posted 2014-06-03T03:33:34.090

Reputation: 166