commit 5a078dfe240210c7a7807a829d53c3dc8250cc13
parent 7da961ec6c11d8bc5d9133d6147a12ae4a4768b2
Author: Kris Maglione <kris@suckless.org>
Date: Tue, 1 Jun 2010 23:05:19 -0400
Kill client process (if possible) on at the slay commans.
Diffstat:
4 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c
@@ -5,6 +5,7 @@
#include "dat.h"
#include <ctype.h>
#include <strings.h>
+#include <signal.h>
#include <X11/Xatom.h>
#include "fns.h"
@@ -628,10 +629,25 @@ client_message(Client *c, char *msg, long l2) {
void
client_kill(Client *c, bool nice) {
- if(nice && (c->proto & ProtoDelete)) {
+ char **host;
+ ulong *pid;
+ long n;
+
+ if(!nice) {
+ getprop_textlist(&c->w, "WM_CLIENT_MACHINE", &host);
+ n = getprop_ulong(&c->w, Net("WM_PID"), "CARDINAL", 0, &pid, 1);
+ if(n && *host && !strcmp(hostname, *host))
+ kill((uint)*pid, SIGKILL);
+ freestringlist(host);
+ free(pid);
+
+ XKillClient(display, c->w.xid);
+ }
+ else if(c->proto & ProtoDelete) {
client_message(c, "WM_DELETE_WINDOW", 0);
ewmh_pingclient(c);
- }else
+ }
+ else
XKillClient(display, c->w.xid);
}
diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h
@@ -11,6 +11,8 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <limits.h>
#include <utf.h>
#include <ixp.h>
#include <stuff/x.h>
@@ -316,13 +318,13 @@ EXTERN struct {
bool sel;
} disp;
-EXTERN Client* client;
-EXTERN View* view;
-EXTERN View* selview;
-EXTERN Key* key;
-EXTERN Divide* divs;
EXTERN Client c_magic;
EXTERN Client c_root;
+EXTERN Client* client;
+EXTERN Divide* divs;
+EXTERN Key* key;
+EXTERN View* selview;
+EXTERN View* view;
EXTERN Handlers framehandler;
@@ -331,17 +333,18 @@ EXTERN IxpServer srv;
EXTERN Ixp9Srv p9srv;
/* X11 */
-EXTERN uint valid_mask;
-EXTERN uint numlock_mask;
-EXTERN Image* ibuf;
EXTERN Image* ibuf32;
+EXTERN Image* ibuf;
+EXTERN uint numlock_mask;
+EXTERN uint valid_mask;
/* Misc */
-EXTERN int starting;
-EXTERN bool resizing;
+EXTERN char* execstr;
+EXTERN char hostname[HOST_NAME_MAX + 1];
EXTERN long ignoreenter;
+EXTERN bool resizing;
+EXTERN int starting;
EXTERN char* user;
-EXTERN char* execstr;
EXTERN long xtime;
EXTERN Client* kludge;
diff --git a/cmd/wmii/fs.c b/cmd/wmii/fs.c
@@ -5,7 +5,6 @@
#include <ctype.h>
#include <stdarg.h>
#include <time.h>
-#include <unistd.h>
#include "fns.h"
typedef union IxpFileIdU IxpFileIdU;
diff --git a/cmd/wmii/main.c b/cmd/wmii/main.c
@@ -12,7 +12,6 @@
#include <pwd.h>
#include <sys/signal.h>
#include <sys/stat.h>
-#include <unistd.h>
#include "fns.h"
static const char
@@ -382,6 +381,7 @@ extern int fmtevent(Fmt*);
passwd = getpwuid(getuid());
user = estrdup(passwd->pw_name);
+ gethostname(hostname, sizeof(hostname) - 1);
init_environment();