return TDM_ERROR_NONE;
}
-static void
-_tdm_vblank_get_process_name(pid_t pid, char *name, unsigned int size)
-{
- char proc[TDM_NAME_LEN], pname[TDM_NAME_LEN];
- FILE *h;
- size_t len;
-
- snprintf(proc, TDM_NAME_LEN, "/proc/%d/cmdline", pid);
- h = fopen(proc, "r");
- if (!h)
- return;
-
- len = fread(pname, sizeof(char), TDM_NAME_LEN, h);
- if (len == 0) {
- char *p = strncpy(pname, "NO NAME", sizeof(pname) - 1);
- len = p - pname;
- }
- pname[len - 1] = '\0';
-
- strncpy(name, pname, size - 1);
- name[size - 1] = '\0';
-
- fclose(h);
-}
-
INTERN void
tdm_vblank_get_vblank_list_information(tdm_display *dpy, char *reply, int *len)
{
pthread_mutex_lock(&valid_list_lock);
LIST_FOR_EACH_ENTRY(v, &valid_vblank_list, valid_link) {
struct wl_client *client = wl_resource_get_client(v->resource);
- char proc_name[TDM_NAME_LEN];
+ const char *proc_name = NULL;
pid_t pid = 0;
- snprintf(proc_name, TDM_NAME_LEN, "Unknown");
if (client) {
wl_client_get_credentials(client, &pid, NULL, NULL);
- _tdm_vblank_get_process_name(pid, proc_name, TDM_NAME_LEN);
+ proc_name = tdm_server_get_client_name(pid);
}
TDM_SNPRINTF(reply, len, "%-12s %u %d %u %s (pid: %u)\n",
- v->name, v->fps, v->offset, v->enable_fake, proc_name, pid);
+ v->name, v->fps, v->offset, v->enable_fake,
+ (proc_name) ? proc_name : "Unknown", pid);
}
pthread_mutex_unlock(&valid_list_lock);