aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
Diffstat (limited to 'procps')
-rw-r--r--procps/ps.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 3002fb9ad..e954da66f 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -157,7 +157,21 @@ static unsigned get_kernel_HZ(void)
157 157
158static void func_user(char *buf, int size, const procps_status_t *ps) 158static void func_user(char *buf, int size, const procps_status_t *ps)
159{ 159{
160#if 1
160 safe_strncpy(buf, get_cached_username(ps->uid), size+1); 161 safe_strncpy(buf, get_cached_username(ps->uid), size+1);
162#else
163 /* "compatible" version, but it's larger */
164 /* procps 2.18 shows numeric UID if name overflows the field */
165 /* TODO: get_cached_username() returns numeric string if
166 * user has no passwd record, we will display it
167 * left-justified here; too long usernames are shown
168 * as _right-justified_ IDs. Is it worth fixing? */
169 const char *user = get_cached_username(ps->uid);
170 if (strlen(user) <= size)
171 safe_strncpy(buf, get_cached_username(ps->uid), size+1);
172 else
173 sprintf(buf, "%*u", size, (unsigned)ps->uid);
174#endif
161} 175}
162 176
163static void func_comm(char *buf, int size, const procps_status_t *ps) 177static void func_comm(char *buf, int size, const procps_status_t *ps)