Changeset View
Changeset View
Standalone View
Standalone View
head/bin/ps/ps.c
Show First 20 Lines • Show All 1,258 Lines • ▼ Show 20 Lines | fmt(char **(*fn)(kvm_t *, const struct kinfo_proc *, int), KINFO *ki, | ||||
return (s); | return (s); | ||||
} | } | ||||
#define UREADOK(ki) (forceuread || (ki->ki_p->ki_flag & P_INMEM)) | #define UREADOK(ki) (forceuread || (ki->ki_p->ki_flag & P_INMEM)) | ||||
static void | static void | ||||
saveuser(KINFO *ki) | saveuser(KINFO *ki) | ||||
{ | { | ||||
char tdname[COMMLEN + 1]; | |||||
char *argsp; | char *argsp; | ||||
if (ki->ki_p->ki_flag & P_INMEM) { | if (ki->ki_p->ki_flag & P_INMEM) { | ||||
/* | /* | ||||
* The u-area might be swapped out, and we can't get | * The u-area might be swapped out, and we can't get | ||||
* at it because we have a crashdump and no swap. | * at it because we have a crashdump and no swap. | ||||
* If it's here fill in these fields, otherwise, just | * If it's here fill in these fields, otherwise, just | ||||
* leave them 0. | * leave them 0. | ||||
*/ | */ | ||||
ki->ki_valid = 1; | ki->ki_valid = 1; | ||||
} else | } else | ||||
ki->ki_valid = 0; | ki->ki_valid = 0; | ||||
/* | /* | ||||
* save arguments if needed | * save arguments if needed | ||||
*/ | */ | ||||
if (needcomm) { | if (needcomm) { | ||||
if (ki->ki_p->ki_stat == SZOMB) | if (ki->ki_p->ki_stat == SZOMB) { | ||||
ki->ki_args = strdup("<defunct>"); | ki->ki_args = strdup("<defunct>"); | ||||
else if (UREADOK(ki) || (ki->ki_p->ki_args != NULL)) | } else if (UREADOK(ki) || (ki->ki_p->ki_args != NULL)) { | ||||
(void)snprintf(tdname, sizeof(tdname), "%s%s", | |||||
ki->ki_p->ki_tdname, ki->ki_p->ki_moretdname); | |||||
ki->ki_args = fmt(kvm_getargv, ki, | ki->ki_args = fmt(kvm_getargv, ki, | ||||
ki->ki_p->ki_comm, ki->ki_p->ki_tdname, MAXCOMLEN); | ki->ki_p->ki_comm, tdname, COMMLEN * 2 + 1); | ||||
else { | } else { | ||||
asprintf(&argsp, "(%s)", ki->ki_p->ki_comm); | asprintf(&argsp, "(%s)", ki->ki_p->ki_comm); | ||||
ki->ki_args = argsp; | ki->ki_args = argsp; | ||||
} | } | ||||
if (ki->ki_args == NULL) | if (ki->ki_args == NULL) | ||||
xo_errx(1, "malloc failed"); | xo_errx(1, "malloc failed"); | ||||
} else { | } else { | ||||
ki->ki_args = NULL; | ki->ki_args = NULL; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |