Hi, Some time ago the process id was aded to process accounting. It would be useful to have the pid in lastcomm(1) output for post mortem analysis. I put it in brackets after the command, like syslogd does it in log files. Without additional column, existing parsers should not be too confused.
old: ssh - bluhm ttyp9 0.31 secs Fri Jan 27 20:57 (0:00:08.72) new: ssh[48913] - bluhm ttyp9 0.31 secs Fri Jan 27 20:57 (0:00:08.72) The line was rather long before, my diff does not make it much worse. ok? bluhm Index: usr.bin/lastcomm/lastcomm.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/usr.bin/lastcomm/lastcomm.c,v retrieving revision 1.31 diff -u -p -r1.31 lastcomm.c --- usr.bin/lastcomm/lastcomm.c 4 Dec 2022 23:50:48 -0000 1.31 +++ usr.bin/lastcomm/lastcomm.c 27 Jan 2023 20:03:31 -0000 @@ -106,6 +106,8 @@ main(int argc, char *argv[]) err(1, "%s", acctfile); for (;;) { + char commpid[sizeof(ab.ac_comm) + 13]; + if (fread(&ab, sizeof(struct acct), 1, fp) != 1) err(1, "%s", acctfile); @@ -117,12 +119,14 @@ main(int argc, char *argv[]) p < &ab.ac_comm[sizeof ab.ac_comm] && *p; ++p) if (!isprint((unsigned char)*p)) *p = '?'; + snprintf(commpid, sizeof(commpid), "%s[%d]", + ab.ac_comm, ab.ac_pid); if (!*argv || requested(argv, &ab)) { t = expand(ab.ac_utime) + expand(ab.ac_stime); (void)printf("%-*.*s %-7s %-*.*s %-*.*s %6.2f secs %.16s", - (int)sizeof ab.ac_comm, - (int)sizeof ab.ac_comm, - ab.ac_comm, flagbits(ab.ac_flag), UT_NAMESIZE, + (int)sizeof commpid, + (int)sizeof commpid, + commpid, flagbits(ab.ac_flag), UT_NAMESIZE, UT_NAMESIZE, user_from_uid(ab.ac_uid, 0), UT_LINESIZE, UT_LINESIZE, getdev(ab.ac_tty), t / (double)AHZ, ctime(&ab.ac_btime));