aboutsummaryrefslogtreecommitdiff
path: root/toys/who.c
diff options
context:
space:
mode:
authorLuis Felipe Strano Moraes <lfelipe@profusion.mobi>2012-02-07 09:15:17 -0800
committerLuis Felipe Strano Moraes <lfelipe@profusion.mobi>2012-02-07 09:15:17 -0800
commit0352f4257da11908b211d704a9ef38e0055711e5 (patch)
treec895a1498039aca73e0459fe1f6c7bba792c9fbf /toys/who.c
parent5232ac079353fb3779e480b74e87c714af6ee707 (diff)
downloadtoybox-0352f4257da11908b211d704a9ef38e0055711e5.tar.gz
Added time to the output of who command.
Diffstat (limited to 'toys/who.c')
-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();