Blob Blame History Raw
diff -up ./lastcomm.1.ori ./lastcomm.1
--- ./lastcomm.1.ori	2017-02-13 10:18:15.394190398 +0100
+++ ./lastcomm.1	2017-02-13 11:37:28.993835576 +0100
@@ -122,7 +122,10 @@ format as your current machine, but has
 .B AHZ.
 .TP
 .B \-p, \-\-show\-paging
-Print paging statistics
+Print paging statistics.
+.TP
+.B \-\-pid
+Show PID and PPID of the process if acct version 3 format is supported by kernel.
 .TP
 .B \-\-debug
 Print verbose internal information.
diff -up ./lastcomm.c.ori ./lastcomm.c
--- ./lastcomm.c.ori	2017-02-08 17:06:24.909802191 +0100
+++ ./lastcomm.c	2017-02-13 10:51:28.019625702 +0100
@@ -77,6 +77,8 @@ char *program_name;		/* name of the prog
 
 int show_paging = 0;		/* If they want paging stats, print 'em */
 
+char show_pid = 0;
+
 static unsigned int hzval;
 
 /* Here are various lists for the user to specify entries that they
@@ -125,6 +127,9 @@ int main(int argc, char *argv[])
         { "show-paging", no_argument, NULL, 11 },
 #endif
         { "forwards", no_argument, NULL, 12 },
+#ifdef LINUX_MULTIFORMAT
+        { "pid", no_argument, NULL, 13},
+#endif
         { 0, 0, 0, 0 }
       };
 
@@ -209,6 +214,9 @@ int main(int argc, char *argv[])
             }
           backwards = 0;
           break;
+        case 13:
+          show_pid = 1;
+          break;
         case 'h':
         case 3:
           /* This should fall through to default! */
@@ -304,6 +312,7 @@ void give_usage(void)
 #ifdef HAVE_PAGING
                "[--show-paging] "
 #endif
+               "[--pid] "
                "[--ahz <freq>] [--version] [--help]\n", program_name);
   print_acct_file_location ();
 }
@@ -392,8 +401,8 @@ void parse_entries(void)
             (void)putchar(' ');
 
           btime = (time_t) rec->ac_btime;
-          if ( show_paging == 0 )
-            (void)printf(" %-8.8s %-8.8s %6.2f secs %-16.16s\n",
+          if ( show_paging == 0)
+            (void)printf(" %-8.8s %-8.8s %6.2f secs %-16.16s",
                          this_uid, this_dev,
 #ifdef LINUX_MULTIFORMAT
                          ((ut + st) / (double) rec->ac_ahz),
@@ -403,7 +412,7 @@ void parse_entries(void)
                          ctime (&btime));
           else
 #ifdef HAVE_PAGING
-            (void)printf(" %6.0fmin %6.0fmaj %4.0fswp %6.2f secs %-16.16s\n",
+            (void)printf(" %6.0fmin %6.0fmaj %4.0fswp %6.2f secs %-16.16s",
                          minf, majf, swap,
 #ifdef LINUX_MULTIFORMAT
                          ((ut + st) / (double) rec->ac_ahz),
@@ -412,8 +421,24 @@ void parse_entries(void)
 #endif
                          ctime (&btime));
 #else
-            (void)printf("  --- No paging statistics! --- \n" );
+            (void)printf("  --- No paging statistics! ---  " );
 #endif
+
+
+          if (show_pid)
+          {
+#ifdef LINUX_MULTIFORMAT
+            if ((rec->ac_version & 0x7f) == 3)
+            {
+              (void) printf(" %d %d", rec->ac_pid, rec->ac_ppid);
+            }
+#else
+            (void)printf("  --- No PID information available! --- " );
+#endif
+          }
+
+
+          (void) printf("\n");
         }
     }
 }