3
Copyright 1988, 1998 The Open Group
5
Permission to use, copy, modify, distribute, and sell this software and its
6
documentation for any purpose is hereby granted without fee, provided that
7
the above copyright notice appear in all copies and that both that
8
copyright notice and this permission notice appear in supporting
11
The above copyright notice and this permission notice shall be included
12
in all copies or substantial portions of the Software.
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
OTHER DEALINGS IN THE SOFTWARE.
22
Except as contained in this notice, the name of a copyright holder shall
23
not be used in advertising or otherwise to promote the sale, use or
24
other dealings in this Software without prior written authorization
25
from the copyright holder.
30
* xdm - display manager daemon
31
* Author: Keith Packard, MIT X Consortium
33
* pseudoReset -- pretend to reset the server by killing all clients
34
* with windows. It will reset the server most of the time, unless
35
* a client remains connected with no windows.
47
ignoreErrors(Display *dspl ATTR_UNUSED, XErrorEvent *event ATTR_UNUSED)
49
debug("ignoring error\n");
54
* this is mostly bogus -- but quite useful. I wish the protocol
55
* had some way of enumerating and identifying clients, that way
56
* this code wouldn't have to be this kludgy.
60
killWindows(Window window)
62
Window root, parent, *children;
63
unsigned int child, nchildren = 0;
65
while (XQueryTree(dpy, window, &root, &parent, &children, &nchildren) &&
67
for (child = 0; child < nchildren; child++) {
68
debug("XKillClient %p\n", children[child]);
69
XKillClient(dpy, children[child]);
75
static Jmp_buf resetJmp;
79
abortReset(int n ATTR_UNUSED)
85
* this display connection better not have any windows...
93
if (Setjmp(resetJmp)) {
94
logError("pseudoReset timeout\n");
96
(void)Signal(SIGALRM, abortReset);
98
XSetErrorHandler(ignoreErrors);
99
for (screen = 0; screen < ScreenCount(dpy); screen++) {
100
debug("pseudoReset screen %d\n", screen);
101
killWindows(RootWindow(dpy, screen));
103
debug("before XSync\n");
107
Signal(SIGALRM, SIG_DFL);
108
XSetErrorHandler((XErrorHandler)0);
109
debug("pseudoReset done\n");