aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/who.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/toys/who.c b/toys/who.c
index b61d81f2..d5d85669 100644
--- a/toys/who.c
+++ b/toys/who.c
@@ -21,6 +21,7 @@ config WHO
*/
#include "toys.h"
+#include <time.h>
#include <utmpx.h>
void who_main(void)
@@ -30,8 +31,17 @@ void who_main(void)
setutxent();
while ((entry = getutxent())) {
- if (entry->ut_type == USER_PROCESS)
- printf("%s %s (%s)\n", entry->ut_user, entry->ut_line, entry->ut_host);
+ if (entry->ut_type == USER_PROCESS) {
+ time_t time;
+ int time_size;
+ char * times;
+
+ time = entry->ut_tv.tv_sec;
+ times = ctime(&time);
+ time_size = strlen(times) - 2;
+ printf("%s\t%s\t%*.*s\t(%s)\n", entry->ut_user, entry->ut_line, time_size, time_size, ctime(&time), entry->ut_host);
+
+ }
}
endutxent();