[hackers] [wmii] Kill client process (if possible) on at the slay commans. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Wed, 2 Jun 2010 03:05:34 +0000 (UTC)

changeset: 2687:96bacb89dc40
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Tue Jun 01 23:05:19 2010 -0400
files: cmd/wmii/client.c cmd/wmii/dat.h cmd/wmii/fs.c cmd/wmii/main.c
description:
Kill client process (if possible) on at the slay commans.

diff -r 5a37afb52596 -r 96bacb89dc40 cmd/wmii/client.c
--- a/cmd/wmii/client.c Tue Jun 01 22:38:33 2010 -0400
+++ b/cmd/wmii/client.c Tue Jun 01 23:05:19 2010 -0400
@@ -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 @@
 
 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 -r 5a37afb52596 -r 96bacb89dc40 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Tue Jun 01 22:38:33 2010 -0400
+++ b/cmd/wmii/dat.h Tue Jun 01 23:05:19 2010 -0400
@@ -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 @@
         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 Ixp9Srv p9srv;
 
 /* X11 */
+EXTERN Image* ibuf32;
+EXTERN Image* ibuf;
+EXTERN uint numlock_mask;
 EXTERN uint valid_mask;
-EXTERN uint numlock_mask;
-EXTERN Image* ibuf;
-EXTERN Image* ibuf32;
 
 /* Misc */
+EXTERN char* execstr;
+EXTERN char hostname[HOST_NAME_MAX + 1];
+EXTERN long ignoreenter;
+EXTERN bool resizing;
 EXTERN int starting;
-EXTERN bool resizing;
-EXTERN long ignoreenter;
 EXTERN char* user;
-EXTERN char* execstr;
 EXTERN long xtime;
 
 EXTERN Client* kludge;
diff -r 5a37afb52596 -r 96bacb89dc40 cmd/wmii/fs.c
--- a/cmd/wmii/fs.c Tue Jun 01 22:38:33 2010 -0400
+++ b/cmd/wmii/fs.c Tue Jun 01 23:05:19 2010 -0400
@@ -5,7 +5,6 @@
 #include <ctype.h>
 #include <stdarg.h>
 #include <time.h>
-#include <unistd.h>
 #include "fns.h"
 
 typedef union IxpFileIdU IxpFileIdU;
diff -r 5a37afb52596 -r 96bacb89dc40 cmd/wmii/main.c
--- a/cmd/wmii/main.c Tue Jun 01 22:38:33 2010 -0400
+++ b/cmd/wmii/main.c Tue Jun 01 23:05:19 2010 -0400
@@ -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 @@
 
         passwd = getpwuid(getuid());
         user = estrdup(passwd->pw_name);
+ gethostname(hostname, sizeof(hostname) - 1);
 
         init_environment();
 
Received on Wed Jun 02 2010 - 03:05:34 UTC

This archive was generated by hypermail 2.2.0 : Wed Jun 02 2010 - 03:12:04 UTC