From 0352f4257da11908b211d704a9ef38e0055711e5 Mon Sep 17 00:00:00 2001 From: Luis Felipe Strano Moraes Date: Tue, 7 Feb 2012 09:15:17 -0800 Subject: Added time to the output of who command. --- toys/who.c | 14 ++++++++++++-- 1 file 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 #include 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(); -- cgit v1.2.3