# include <unistd.h>
#endif
+#ifdef HAVE_SIGNAL_H
+# include <signal.h> /* for kill() */
+#endif
+
#include <glib.h>
#include <X11/Xutil.h>
if (got) {
gchar localhost[128];
+ guint32 pid;
gethostname(localhost, 127);
localhost[127] = '\0';
self->client_machine = s;
else
g_free(s);
+
+ /* see if it has the PID set too (the PID requires that the
+ WM_CLIENT_MACHINE be set) */
+ if (PROP_GET32(self->window, net_wm_pid, cardinal, &pid))
+ self->pid = pid;
}
}
/* in the case that the client provides no means to requesting that it
close, we just kill it */
if (!self->delete_window)
- client_kill(self);
-
- if (self->not_responding)
+ /* don't use client_kill(), we should only kill based on PID in
+ response to a lack of PING replies */
+ XKillClient(ob_display, self->window);
+ else if (self->not_responding)
client_kill(self);
else {
PROP_MSG_TO(self->window, self->window, wm_protocols,
void client_kill(ObClient *self)
{
- XKillClient(ob_display, self->window);
+ if (!self->client_machine && self->pid) {
+ /* running on the local host */
+ if (!self->kill_tried_term) {
+ kill(self->pid, SIGTERM);
+ self->kill_tried_term = TRUE;
+ }
+ else
+ kill(self->pid, SIGKILL); /* kill -9 */
+ }
+ else
+ XKillClient(ob_display, self->window);
}
void client_hilite(ObClient *self, gboolean hilite)
#include <glib.h>
#include <X11/Xlib.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h> /* for pid_t */
+#endif
+
struct _ObFrame;
struct _ObGroup;
struct _ObSessionState;
gchar *client_machine;
/*! The command used to run the program. Pre-XSMP window identification. */
gchar *wm_command;
+ /*! The PID of the process which owns the window */
+ pid_t pid;
/*! The application that created the window */
gchar *name;
/*! Indicates if the client is trying to close but has stopped responding
to pings */
gboolean not_responding;
+ /*! We tried to kill the client with SIGTERM */
+ gboolean kill_tried_term;
#ifdef SYNC
/*! The client wants to sync during resizes */
CREATE(net_wm_strut_partial, "_NET_WM_STRUT_PARTIAL");
CREATE(net_wm_icon, "_NET_WM_ICON");
CREATE(net_wm_icon_geometry, "_NET_WM_ICON_GEOMETRY");
-/* CREATE(net_wm_pid, "_NET_WM_PID"); */
+ CREATE(net_wm_pid, "_NET_WM_PID");
CREATE(net_wm_allowed_actions, "_NET_WM_ALLOWED_ACTIONS");
CREATE(net_wm_user_time, "_NET_WM_USER_TIME");
/* CREATE(net_wm_user_time_window, "_NET_WM_USER_TIME_WINDOW"); */