process: Make sure Linux always parses cmdline.

This commit is contained in:
Alastair Poole 2020-05-09 00:14:30 +01:00
parent fc60c351ca
commit a80d244476
1 changed files with 16 additions and 18 deletions

View File

@ -177,29 +177,27 @@ _cmd_args(Proc_Info *p, int pid, char *name, size_t len)
snprintf(name, len, "%s", ecore_file_file_get(link)); snprintf(name, len, "%s", ecore_file_file_get(link));
free(link); free(link);
} }
else
FILE *f = fopen(eina_slstr_printf("/proc/%d/cmdline", pid), "r");
if (f)
{ {
FILE *f = fopen(eina_slstr_printf("/proc/%d/cmdline", pid), "r"); if (fgets(line, sizeof(line), f))
if (f)
{ {
if (fgets(line, sizeof(line), f)) Eina_Strbuf *buf = eina_strbuf_new();
const char *n;
if (ecore_file_exists(line))
snprintf(name, len, "%s", ecore_file_file_get(line));
n = line;
while (*n && (*n + 1))
{ {
Eina_Strbuf *buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, "%s ", n);
const char *n; n = strchr(n, '\0') + 1;
if (ecore_file_exists(line))
snprintf(name, len, "%s", ecore_file_file_get(line));
n = line;
while (*n && (*n + 1))
{
eina_strbuf_append_printf(buf, "%s ", n);
n = strchr(n, '\0') + 1;
}
p->arguments = eina_strbuf_release(buf);
} }
fclose(f); p->arguments = eina_strbuf_release(buf);
} }
fclose(f);
} }
char *end = strchr(name, ' '); char *end = strchr(name, ' ');