Lines 328-334
static bool get_proc_stat(char *pid, char *format_str, struct procstat* prs,
Link Here
|
328 |
/* scan in pid, and the command, in linux the command is a max of 15 chars |
328 |
/* scan in pid, and the command, in linux the command is a max of 15 chars |
329 |
* plus a terminating NULL byte; prs->comm will be NULL terminated since |
329 |
* plus a terminating NULL byte; prs->comm will be NULL terminated since |
330 |
* that area of memory is all zerored out when prs is allocated */ |
330 |
* that area of memory is all zerored out when prs is allocated */ |
331 |
if (sscanf(stat_text, "%d (%15c", &prs->pid, prs->comm) != 2) |
331 |
/* Apparently %15c means 'exactly 15' but a glibc bug allows matching |
|
|
332 |
* regardles. musl won't match it. |
333 |
* See: https://www.openwall.com/lists/musl/2013/11/15/5 |
334 |
* and: https://sourceware.org/bugzilla/show_bug.cgi?id=12701 */ |
335 |
if (sscanf(stat_text, "%d (%c", &prs->pid, prs->comm) != 2) |
332 |
/* we might get an empty command name, so check for it: |
336 |
/* we might get an empty command name, so check for it: |
333 |
* do the open and close parenteses lie next to each other? |
337 |
* do the open and close parenteses lie next to each other? |
334 |
* proceed if yes, finish otherwise |
338 |
* proceed if yes, finish otherwise |
Lines 393-399
static void eval_link(char *pid, char *link_rel, enum field field, char **ptr,
Link Here
|
393 |
* for the cwd symlink, since on linux the links we care about will never |
397 |
* for the cwd symlink, since on linux the links we care about will never |
394 |
* be relative links (cwd, exec) |
398 |
* be relative links (cwd, exec) |
395 |
* Doing this because readlink works on static buffers */ |
399 |
* Doing this because readlink works on static buffers */ |
396 |
link = canonicalize_file_name(link_file); |
400 |
/* canonicalize_file_name is no good for musl, use realpath instead */ |
|
|
401 |
link = realpath(link_file, NULL); |
397 |
/* we no longer need need the path to the link file */ |
402 |
/* we no longer need need the path to the link file */ |
398 |
obstack_free(mem_pool, link_file); |
403 |
obstack_free(mem_pool, link_file); |