Kill client process (if possible) on at the slay commans.

This commit is contained in:
Kris Maglione 2010-06-01 23:05:19 -04:00
parent 7da961ec6c
commit 5a078dfe24
4 changed files with 34 additions and 16 deletions

View File

@ -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);
}

View File

@ -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 long ignoreenter;
EXTERN char* user;
EXTERN char* execstr;
EXTERN char hostname[HOST_NAME_MAX + 1];
EXTERN long ignoreenter;
EXTERN bool resizing;
EXTERN int starting;
EXTERN char* user;
EXTERN long xtime;
EXTERN Client* kludge;

View File

@ -5,7 +5,6 @@
#include <ctype.h>
#include <stdarg.h>
#include <time.h>
#include <unistd.h>
#include "fns.h"
typedef union IxpFileIdU IxpFileIdU;

View File

@ -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();