]> git.cameronkatri.com Git - getent-darwin.git/blobdiff - getent.c
Also print UNIX timestamps in getent utmpx output.
[getent-darwin.git] / getent.c
index bc76825dd44929cc87357c799422619813477cad..d19eac6671617d20a1272fea5be851708a82a910 100644 (file)
--- a/getent.c
+++ b/getent.c
@@ -55,8 +55,9 @@ __FBSDID("$FreeBSD$");
 #include <limits.h>
 #include <netdb.h>
 #include <pwd.h>
-#include <stdio.h>
 #include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -583,7 +584,9 @@ utmpxprint(const struct utmpx *ut)
        if (ut->ut_type == EMPTY)
                return;
        
-       printf("[%.24s] ", ctime(&ut->ut_tv.tv_sec));
+       printf("[%jd.%06u -- %.24s] ",
+           (intmax_t)ut->ut_tv.tv_sec, (unsigned int)ut->ut_tv.tv_usec,
+           ctime(&ut->ut_tv.tv_sec));
 
        switch (ut->ut_type) {
        case BOOT_TIME:
@@ -601,13 +604,13 @@ utmpxprint(const struct utmpx *ut)
        case USER_PROCESS:
                printf("user process: id=\"");
                UTMPXPRINTID;
-               printf("\" user=\"%s\" line=\"%s\" host=\"%s\"\n",
-                   ut->ut_user, ut->ut_line, ut->ut_host);
+               printf("\" pid=\"%d\" user=\"%s\" line=\"%s\" host=\"%s\"\n",
+                   ut->ut_pid, ut->ut_user, ut->ut_line, ut->ut_host);
                break;
        case DEAD_PROCESS:
                printf("dead process: id=\"");
                UTMPXPRINTID;
-               printf("\"\n");
+               printf("\" pid=\"%d\"\n", ut->ut_pid);
                break;
        default:
                printf("unknown record type\n");