buf[sz] = ' ';
sz--;
}
+ if (base[0] == '-') /* "-sh" (login shell)? */
+ base++;
/* If comm differs from argv0, prepend "{comm} ".
* It allows to see thread names set by prctl(PR_SET_NAME).
*/
- if (base[0] == '-') /* "-sh" (login shell)? */
- base++;
+ if (!comm)
+ return;
comm_len = strlen(comm);
/* Why compare up to comm_len, not COMM_LEN-1?
* Well, some processes rewrite argv, and use _spaces_ there
buf[col - 1] = '\0';
}
} else {
- snprintf(buf, col, "[%s]", comm);
+ snprintf(buf, col, "[%s]", comm ? comm : "?");
}
}
//usage:#define pmap_trivial_usage
//usage: "[-xq] PID"
//usage:#define pmap_full_usage "\n\n"
-//usage: "Display detailed process memory usage"
+//usage: "Display process memory usage"
//usage: "\n"
//usage: "\n -x Show details"
//usage: "\n -q Quiet"
int ret;
char buf[256];
- read_cmdline(buf, sizeof(buf), pid, "no such process");
+ read_cmdline(buf, sizeof(buf), pid, NULL);
printf("%u: %s\n", (int)pid, buf);
if (!(opt & OPT_q) && (opt & OPT_x))