Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!spool.mu.edu!uunet!math.fu-berlin.de!opal!unido!laura!tommy!klute From: klute@tommy.informatik.uni-dortmund.de (Rainer Klute) Newsgroups: comp.windows.x Subject: Re: Remote Xserver shutdown Keywords: PC X Sight Message-ID: <3125@laura.UUCP> Date: 26 Mar 91 08:49:19 GMT References: <62@uarthur.UUCP> Sender: news@laura.UUCP Reply-To: klute@tommy.informatik.uni-dortmund.de (Rainer Klute) Organization: University of Dortmund, Germany Lines: 92 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 #include #include 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