version 1.99, 2019/10/06 15:08:54 |
version 1.100, 2019/10/08 20:51:03 |
|
|
} |
} |
|
|
char * |
char * |
format_header(char *second_field, int show_threads) |
format_header(char *second_field) |
{ |
{ |
char *field_name, *thread_field = " TID"; |
char *field_name, *thread_field = " TID"; |
char *ptr; |
char *ptr; |
|
|
if (show_threads) |
field_name = second_field ? second_field : thread_field; |
field_name = thread_field; |
|
else |
|
field_name = second_field; |
|
|
|
ptr = header + UNAME_START; |
ptr = header + UNAME_START; |
while (*field_name != '\0') |
while (*field_name != '\0') |
|
|
|
|
char * |
char * |
format_next_process(struct handle *hndl, const char *(*get_userid)(uid_t, int), |
format_next_process(struct handle *hndl, const char *(*get_userid)(uid_t, int), |
pid_t *pid, int show_threads) |
pid_t *pid) |
{ |
{ |
char *p_wait; |
char *p_wait; |
struct kinfo_proc *pp; |
struct kinfo_proc *pp; |
|
|
else |
else |
p_wait = "-"; |
p_wait = "-"; |
|
|
if (show_threads) |
if (get_userid == NULL) |
snprintf(buf, sizeof(buf), "%8d", pp->p_tid); |
snprintf(buf, sizeof(buf), "%8d", pp->p_tid); |
else |
else |
snprintf(buf, sizeof(buf), "%s", (*get_userid)(pp->p_ruid, 0)); |
snprintf(buf, sizeof(buf), "%s", (*get_userid)(pp->p_ruid, 0)); |