#define KILL_USAGE \
"[COMMAND] [ARG]...\n" \
- "\t-id : the identifier for the resource whose creator is to be killed. (Usage: enlightenment_info -kill -id [id])\n" \
- "\t-name : the name for the resource whose creator is to be killed. (Usage: enlightenment_info -kill -name [name])\n" \
- "\t-pid(no implement) : the pid for the resource whose creator is to be killed. (Usage: enlightenment_info -kill -pid [pid])\n" \
- "\t-all(no implement) : kill all clients with top level windows\n" \
+ "\t-id : the identifier for the resource whose creator is to be killed.\n" \
+ "\t-name : the name for the resource whose creator is to be killed.\n" \
+ "\t-pid : the pid for the resource whose creator is to be killed.\n" \
+ "\t-all : kill all clients with top level windows\n" \
"\t-help\n" \
+ "Example:\n" \
+ "\tenlightenment_info -kill\n" \
+ "\tenlightenment_info -kill [win_id]\n" \
+ "\tenlightenment_info -kill -id [win_id]\n" \
+ "\tenlightenment_info -kill -name [win_name]\n" \
+ "\tenlightenment_info -kill -pid [pid]\n" \
+ "\tenlightenment_info -kill -all\n" \
+ "\tenlightenment_info -kill -help\n" \
static void
_e_info_client_proc_screen_rotation(int argc, char **argv)
{
const static int KILL_ID_MODE = 1;
const static int KILL_NAME_MODE = 2;
+ const static int KILL_PID_MODE = 3;
+ const static int KILL_ALL_MODE = 4;
Eina_Bool res;
uint64_t uint64_value;
const char *str_value = "";
return;
}
}
+ else if (argc == 3)
+ {
+ if (eina_streq(argv[2], "-all"))
+ mode = KILL_ALL_MODE;
+ else if (eina_streq(argv[2], "-help"))
+ goto usage;
+ else
+ {
+ mode = KILL_ID_MODE;
+ if (strlen(argv[2]) >= 2 && argv[2][0] == '0' && argv[2][1] == 'x')
+ res = _util_string_to_ulong(argv[2], (unsigned long *)&uint64_value, 16);
+ else
+ res = _util_string_to_ulong(argv[2], (unsigned long *)&uint64_value, 10);
+
+ EINA_SAFETY_ON_FALSE_GOTO(res, usage);
+ }
+ }
else if (argc == 4)
{
if (eina_streq(argv[2], "-id"))
else
res = _util_string_to_ulong(argv[3], (unsigned long *)&uint64_value, 10);
- EINA_SAFETY_ON_FALSE_RETURN(res);
+ EINA_SAFETY_ON_FALSE_GOTO(res, usage);
}
else if (eina_streq(argv[2], "-name"))
{
mode = KILL_NAME_MODE;
str_value = argv[3];
}
+ else if (eina_streq(argv[2], "-pid"))
+ {
+ mode = KILL_PID_MODE;
+ if (strlen(argv[3]) >= 2 && argv[3][0] == '0' && argv[3][1] == 'x')
+ res = _util_string_to_ulong(argv[3], (unsigned long *)&uint64_value, 16);
+ else
+ res = _util_string_to_ulong(argv[3], (unsigned long *)&uint64_value, 10);
+
+ EINA_SAFETY_ON_FALSE_GOTO(res, usage);
+ }
else
- goto arg_err;
+ goto usage;
}
else
- goto arg_err;
+ goto usage;
res = _e_info_client_eldbus_message_with_args("kill_client",
_e_info_client_cb_kill_client,
EINA_SAFETY_ON_FALSE_RETURN(res);
return;
-arg_err:
+usage:
printf("Usage: enlightenment_info %s", KILL_USAGE);
}
return NULL;
}
+const static int KILL_ID_MODE = 1;
+const static int KILL_NAME_MODE = 2;
+const static int KILL_PID_MODE = 3;
+const static int KILL_ALL_MODE = 4;
+
static int
-_e_info_server_ec_kill_by_name(const char *name, Eldbus_Message_Iter *array_of_string)
+_e_info_server_ec_kill(uint32_t mode, void *value, Eldbus_Message_Iter *array_of_string)
{
E_Client *ec;
Evas_Object *o;
ec_name = e_client_util_name_get(ec) ?: "NO NAME";
- find = strstr(ec_name, name);
+ if (mode == KILL_NAME_MODE)
+ {
+ find = strstr(ec_name, (const char *)value);
- if (find)
+ if (!find)
+ continue;
+ }
+ else if (mode == KILL_PID_MODE)
{
- count++;
- e_client_act_kill_begin(ec);
- snprintf(result, sizeof(result),
- "[Server] killing creator(%s) of resource 0x%lx",
- ec_name, (unsigned long)e_client_util_win_get(ec));
- eldbus_message_iter_arguments_append(array_of_string, VALUE_TYPE_REPLY_KILL, result);
+ pid_t pid = -1;
+ pid = ec->netwm.pid;
+ if (pid <= 0)
+ {
+ if (ec->comp_data)
+ {
+ E_Comp_Wl_Client_Data *cdata = (E_Comp_Wl_Client_Data*)ec->comp_data;
+ if (cdata->surface)
+ wl_client_get_credentials(wl_resource_get_client(cdata->surface), &pid, NULL, NULL);
+ }
+ }
+ if (pid != *(pid_t *)value)
+ continue;
}
+
+ count++;
+ e_client_act_kill_begin(ec);
+
+ snprintf(result, sizeof(result),
+ "[Server] killing creator(%s) of resource 0x%lx",
+ ec_name, (unsigned long)e_client_util_win_get(ec));
+ eldbus_message_iter_arguments_append(array_of_string, VALUE_TYPE_REPLY_KILL, result);
}
return count;
static Eldbus_Message *
_e_info_server_cb_kill_client(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
{
- const static int KILL_ID_MODE = 1;
- const static int KILL_NAME_MODE = 2;
Eldbus_Message *reply = eldbus_message_method_return_new(msg);
Eldbus_Message_Iter *iter = eldbus_message_iter_get(reply);
Eina_Bool res;
"[Server] killing creator(%s) of resource 0x%lx",
e_client_util_name_get(ec) ?: "NO NAME", (unsigned long)win);
}
- else if (mode == KILL_NAME_MODE)
+ else if (mode >= KILL_NAME_MODE && mode <= KILL_ALL_MODE)
{
- count = _e_info_server_ec_kill_by_name(str_value, array_of_string);
+ if (mode == KILL_NAME_MODE)
+ count = _e_info_server_ec_kill(mode, (void *)str_value, array_of_string);
+ else
+ count = _e_info_server_ec_kill(mode, (void *)&uint64_value, array_of_string);
+
snprintf(result, sizeof(result),
- "\n[Server] killed %d client(s)", count);
+ "\n[Server] killed %d client(s)", count);
}
else
{
- snprintf(result, sizeof(result),
- "[Server] Error: wrong mode.");
+ snprintf(result, sizeof(result), "[Server] Error: wrong mode.");
}
finish: