summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xkill.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/xkill.c b/xkill.c
index 069bc19..429a64a 100644
--- a/xkill.c
+++ b/xkill.c
@@ -46,7 +46,6 @@ from The Open Group.
#include <X11/Xmu/WinUtil.h>
-static Display *dpy = NULL;
static char *ProgramName;
#define SelectButtonAny (-1)
@@ -62,7 +61,7 @@ static Bool wm_state_set ( Display *dpy, Window win );
static Bool wm_running ( Display *dpy, int screenno );
static void
-Exit(int code)
+Exit(int code, Display *dpy)
{
if (dpy) {
XCloseDisplay (dpy);
@@ -84,13 +83,14 @@ usage(void)
fprintf (stderr, "usage: %s [-option ...]\n%s",
ProgramName, options);
- Exit (1);
+ Exit (1, NULL);
}
int
main(int argc, char *argv[])
{
int i; /* iterator, temp variable */
+ Display *dpy = NULL;
char *displayname = NULL; /* name of server to contact */
int screenno; /* screen number of dpy */
XID id = None; /* resource to kill */
@@ -137,14 +137,14 @@ main(int argc, char *argv[])
if (!dpy) {
fprintf (stderr, "%s: unable to open display \"%s\"\n",
ProgramName, XDisplayName (displayname));
- Exit (1);
+ Exit (1, dpy);
}
screenno = DefaultScreen (dpy);
if (kill_all) {
if (verify_okay_to_kill (dpy, screenno))
kill_all_windows (dpy, screenno, top);
- Exit (0);
+ Exit (0, dpy);
}
/*
@@ -158,7 +158,7 @@ main(int argc, char *argv[])
if (button_name && !parse_button (button_name, &button)) {
fprintf (stderr, "%s: invalid button specification \"%s\"\n",
ProgramName, button_name);
- Exit (1);
+ Exit (1, dpy);
}
if (button >= 0 || button == SelectButtonFirst) {
@@ -172,7 +172,7 @@ main(int argc, char *argv[])
fprintf (stderr,
"%s: no pointer mapping, can't select window\n",
ProgramName);
- Exit (1);
+ Exit (1, dpy);
}
if (button >= 0) { /* check button */
@@ -183,7 +183,7 @@ main(int argc, char *argv[])
fprintf (stderr,
"%s: no button number %u in pointer map, can't select window\n",
ProgramName, ub);
- Exit (1);
+ Exit (1, dpy);
}
} else { /* get first entry */
button = (int) ((unsigned int) pointer_map[0]);
@@ -215,7 +215,7 @@ main(int argc, char *argv[])
XSync (dpy, 0);
}
- Exit (0);
+ Exit (0, dpy);
/*NOTREACHED*/
return 0;
}
@@ -281,7 +281,7 @@ get_window_id(Display *dpy, int screen, int button, char *msg)
if (cursor == None) {
fprintf (stderr, "%s: unable to create selection cursor\n",
ProgramName);
- Exit (1);
+ Exit (1, dpy);
}
printf ("Select %s with ", msg);
@@ -295,7 +295,7 @@ get_window_id(Display *dpy, int screen, int button, char *msg)
if (XGrabPointer (dpy, root, False, MASK, GrabModeSync, GrabModeAsync,
None, cursor, CurrentTime) != GrabSuccess) {
fprintf (stderr, "%s: unable to grab cursor\n", ProgramName);
- Exit (1);
+ Exit (1, dpy);
}
/* from dsimple.c in xwininfo */