wds@uarthur.UUCP (William D. Sheppard) (03/26/91)
I am trying to figure out a way to kill a PC XSight Server from unix. Basically when using PC Xsight, the server is running on the PC and my clients are running on SPARC stations. When the client exits my aplication I want to be able to return the user back to DOS. Is their anything defined in the X protocol to get a X Server to commit suicide? William Sheppard Consultant World Bank, Washington DC wds@uarthur.UUCP
mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (03/26/91)
> Is their anything defined in the X protocol to get a X Server to > commit suicide? No. In some circumstances (an X terminal, for example) it doesn't even really make sense. The closest thing is that the protocol states than when the last connection to the server closes, with a close-down mode of Destroy, the server is reset. If you're going to have the server suicide, this is certainly the time to do it; MIT servers can, under some circumstances, be set up to do this. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu
klute@tommy.informatik.uni-dortmund.de (Rainer Klute) (03/26/91)
In article <62@uarthur.UUCP>, wds@uarthur.UUCP (William D. Sheppard) writes: |> I am trying to figure out a way to kill a PC XSight Server |> from unix. Basically when using PC Xsight, the server is running |> on the PC and my clients are running on SPARC stations. When the |> client exits my aplication I want to be able to return the user |> back to DOS. Is their anything defined in the X protocol to get |> a X Server to commit suicide? Not directly (as far as I know). But you could try the following: Open the display without creating a window, traverse the window hierarchy (to be obtained by XQueryTree) and kill (XKillWindow) each window you find. If you then close your own display connection the server might reset. "Might" because there might be other display connections without windows which cannot be destroyed by the XQueryTree/XKillWindow procedure. And if you are lucky your server will terminate if it has no more connections to clients. Here is some code to show how to do it: #include <stdio.h> #include <X11/X.h> #include <X11/Xlib.h> static IgnoreErrors (display, event) Display *display; XErrorEvent event; { } static KillWindows (display, window) Display *display; Window window; { Window root, parent, *children; int child; unsigned int noChildren = 0; XSetErrorHandler (IgnoreErrors); while (XQueryTree (display, window, &root, &parent, &children, &noChildren)) { if (noChildren <= 0) break; for (child = 0; child < noChildren; child++) XKillClient (display, children[child]); XFree ((char *) children); }; } main (argc, argv) int argc; char *argv[]; { Display *display; int screen; Window rootWindow; if (argc != 2) { fprintf (stderr, "Usage: %s display\n", argv[0]); exit (1); }; display = XOpenDisplay (argv[1]); if (display == (Display *) 0) { fprintf (stderr, "Could not open display %s.\n", argv[1]); exit (1); }; fprintf (stdout, "Killing all windows on display %s", argv[1]); fflush (stdout); for (screen = 0; screen < ScreenCount (display); screen++) { rootWindow = RootWindow (display, screen); KillWindows (display, rootWindow); }; XSync (display, False); fprintf (stdout, ", done.\n"); } -- Dipl.-Inform. Rainer Klute klute@irb.informatik.uni-dortmund.de Univ. Dortmund, IRB klute@unido.uucp, klute@unido.bitnet Postfach 500500 |)|/ Tel.: +49 231 755-4663 D-4600 Dortmund 50 |\|\ Fax : +49 231 755-2386