vblank: use tdm_server_get_client_name 37/128637/2
authorBoram Park <boram1288.park@samsung.com>
Tue, 2 May 2017 02:35:53 +0000 (11:35 +0900)
committerBoram Park <boram1288.park@samsung.com>
Wed, 10 May 2017 23:12:24 +0000 (08:12 +0900)
Change-Id: I4f47cca1d1f4fa268ab330fd947cd91e5c9458b8

src/tdm_vblank.c

index 662204f5285279938abdd7eadfe562eedaa62f5c..99ce8a01f05897608e8a317ed090ee5b11aad877 100644 (file)
@@ -1109,31 +1109,6 @@ tdm_vblank_set_resource(tdm_vblank *vblank, struct wl_resource *resource)
        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)
 {
@@ -1147,17 +1122,17 @@ 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);