1
/* $Xorg: reset.c,v 1.4 2001/02/09 02:05:40 xorgcvs Exp $ */
4
Copyright 1988, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall
24
not be used in advertising or otherwise to promote the sale, use or
25
other dealings in this Software without prior written authorization
29
/* $XFree86: xc/programs/xdm/reset.c,v 1.3 2001/01/17 23:45:21 dawes Exp $ */
32
* xdm - display manager daemon
33
* Author: Keith Packard, MIT X Consortium
35
* pseudoReset -- pretend to reset the server by killing all clients
36
* with windows. It will reset the server most of the time, unless
37
* a client remains connected with no windows.
41
# include "dm_error.h"
43
# include <X11/Xlib.h>
48
ignoreErrors (Display *dpy, XErrorEvent *event)
50
Debug ("ignoring error\n");
55
* this is mostly bogus -- but quite useful. I wish the protocol
56
* had some way of enumerating and identifying clients, that way
57
* this code wouldn't have to be this kludgy.
61
killWindows (Display *dpy, Window window)
63
Window root, parent, *children;
65
unsigned int nchildren = 0;
67
while (XQueryTree (dpy, window, &root, &parent, &children, &nchildren)
70
for (child = 0; child < nchildren; child++) {
71
Debug ("XKillClient 0x%lx\n", (unsigned long)children[child]);
72
XKillClient (dpy, children[child]);
74
XFree ((char *)children);
78
static Jmp_buf resetJmp;
84
Longjmp (resetJmp, 1);
88
* this display connection better not have any windows...
92
pseudoReset (Display *dpy)
97
if (Setjmp (resetJmp)) {
98
LogError ("pseudoReset timeout\n");
100
(void) Signal (SIGALRM, abortReset);
102
XSetErrorHandler (ignoreErrors);
103
for (screen = 0; screen < ScreenCount (dpy); screen++) {
104
Debug ("pseudoReset screen %d\n", screen);
105
root = RootWindow (dpy, screen);
106
killWindows (dpy, root);
108
Debug ("before XSync\n");
112
Signal (SIGALRM, SIG_DFL);
113
XSetErrorHandler ((XErrorHandler)0 );
114
Debug ("pseudoReset done\n");