-.\" $OpenBSD: acct.5,v 1.25 2021/12/13 16:37:37 deraadt Exp $
+.\" $OpenBSD: acct.5,v 1.26 2022/02/22 17:22:29 deraadt Exp $
.\" $NetBSD: acct.5,v 1.4 1995/10/22 01:40:10 ghudson Exp $
.\"
.\" Copyright (c) 1991, 1993
.\"
.\" @(#)acct.5 8.1 (Berkeley) 6/5/93
.\"
-.Dd $Mdocdate: December 13 2021 $
+.Dd $Mdocdate: February 22 2022 $
.Dt ACCT 5
.Os
.Sh NAME
typedef u_int16_t comp_t;
struct acct {
- char ac_comm[10]; /* command name */
+ char ac_comm[24]; /* command name, incl NUL */
comp_t ac_utime; /* user time */
comp_t ac_stime; /* system time */
comp_t ac_etime; /* elapsed time */
+ comp_t ac_io; /* count of IO blocks */
time_t ac_btime; /* starting time */
uid_t ac_uid; /* user id */
gid_t ac_gid; /* group id */
- u_int16_t ac_mem; /* average memory usage */
- comp_t ac_io; /* count of IO blocks */
+ u_int32_t ac_mem; /* average memory usage */
dev_t ac_tty; /* controlling tty, or -1 */
+ pid_t ac_pid; /* process id */
#define AFORK 0x01 /* fork'd but not exec'd */
#define AMAP 0x04 /* system call or stack mapping violation */
#define APLEDGE 0x20 /* killed due to pledge violation */
#define ATRAP 0x40 /* memory access violation */
#define AUNVEIL 0x80 /* unveil access violation */
- u_int8_t ac_flag; /* accounting flags */
+ u_int32_t ac_flag; /* accounting flags */
};
/*
-/* $OpenBSD: kern_acct.c,v 1.45 2021/12/13 16:37:37 deraadt Exp $ */
+/* $OpenBSD: kern_acct.c,v 1.46 2022/02/22 17:22:29 deraadt Exp $ */
/* $NetBSD: kern_acct.c,v 1.42 1996/02/04 02:15:12 christos Exp $ */
/*-
/* (8) The boolean flags that tell how process terminated or misbehaved. */
acct.ac_flag = pr->ps_acflag;
+ /* Extensions */
+ acct.ac_pid = pr->ps_pid;
+
/*
* Now, just write the accounting information to the file.
*/
-/* $OpenBSD: acct.h,v 1.11 2021/12/13 16:37:37 deraadt Exp $ */
+/* $OpenBSD: acct.h,v 1.12 2022/02/22 17:22:28 deraadt Exp $ */
/* $NetBSD: acct.h,v 1.16 1995/03/26 20:23:52 jtc Exp $ */
/*-
* @(#)acct.h 8.3 (Berkeley) 7/10/94
*/
+#include <sys/syslimits.h>
+
/*
* Accounting structures; these use a comp_t type which is a 3 bits base 8
* exponent, 13 bit fraction ``floating point'' number. Units are 1/AHZ
typedef u_int16_t comp_t;
struct acct {
- char ac_comm[10]; /* command name */
- comp_t ac_utime; /* user time */
- comp_t ac_stime; /* system time */
- comp_t ac_etime; /* elapsed time */
- time_t ac_btime; /* starting time */
- uid_t ac_uid; /* user id */
- gid_t ac_gid; /* group id */
- u_int16_t ac_mem; /* average memory usage */
- comp_t ac_io; /* count of IO blocks */
- dev_t ac_tty; /* controlling tty, or -1 */
+ char ac_comm[_MAXCOMLEN]; /* command name, incl NUL */
+ comp_t ac_utime; /* user time */
+ comp_t ac_stime; /* system time */
+ comp_t ac_etime; /* elapsed time */
+ comp_t ac_io; /* count of IO blocks */
+ time_t ac_btime; /* starting time */
+ uid_t ac_uid; /* user id */
+ gid_t ac_gid; /* group id */
+ u_int32_t ac_mem; /* average memory usage */
+ dev_t ac_tty; /* controlling tty, or -1 */
+ pid_t ac_pid; /* process id */
-#define AFORK 0x01 /* fork'd but not exec'd */
-#define AMAP 0x04 /* system call or stack mapping violation */
-#define ACORE 0x08 /* dumped core */
-#define AXSIG 0x10 /* killed by a signal */
-#define APLEDGE 0x20 /* killed due to pledge violation */
-#define ATRAP 0x40 /* memory access violation */
-#define AUNVEIL 0x80 /* unveil access violation */
- u_int8_t ac_flag; /* accounting flags */
+#define AFORK 0x01 /* fork'd but not exec'd */
+#define AMAP 0x04 /* system call or stack mapping violation */
+#define ACORE 0x08 /* dumped core */
+#define AXSIG 0x10 /* killed by a signal */
+#define APLEDGE 0x20 /* killed due to pledge violation */
+#define ATRAP 0x40 /* memory access violation */
+#define AUNVEIL 0x80 /* unveil access violation */
+ u_int32_t ac_flag; /* accounting flags */
};
/*
-/* $OpenBSD: extern.h,v 1.6 2019/01/17 06:21:46 tedu Exp $ */
+/* $OpenBSD: extern.h,v 1.7 2022/02/22 17:22:29 deraadt Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
* All rights reserved.
*
*/
-#include <sys/param.h> /* MAXCOMLEN */
+#include <sys/sysctl.h>
#include <db.h>
/* structures */
struct cmdinfo {
- char ci_comm[MAXCOMLEN+2]; /* command name (+ '*') */
+ char ci_comm[KI_MAXCOMLEN+1]; /* command name (+ '*') */
uid_t ci_uid; /* user id */
+ pid_t ci_pid; /* pid */
uint64_t ci_calls; /* number of calls */
uint64_t ci_etime; /* elapsed time */
uint64_t ci_utime; /* user time */
uint64_t ci_stime; /* system time */
uint64_t ci_mem; /* memory use */
uint64_t ci_io; /* number of disk i/o ops */
- u_int ci_flags; /* flags; see below */
+ uint32_t ci_flags; /* flags; see below */
};
#define CI_UNPRINTABLE 0x0001 /* unprintable chars in name */
-/* $OpenBSD: main.c,v 1.17 2021/10/24 21:24:19 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.18 2022/02/22 17:22:29 deraadt Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
* All rights reserved.
ci.ci_uid = ac.ac_uid;
ci.ci_mem = ac.ac_mem;
ci.ci_io = decode_comp_t(ac.ac_io) / AHZ;
+ ci.ci_pid = ac.ac_pid;
if (!uflag) {
/* and enter it into the usracct and pacct databases */
if (sflag || (mflag && !qflag))
usracct_add(&ci);
} else if (!qflag)
- printf("%6u %12.2f cpu %12lluk mem %12llu io %s\n",
+ printf("%6u %12.2f cpu %12lluk mem %12llu io pid %u %s\n",
ci.ci_uid,
(ci.ci_utime + ci.ci_stime) / (double) AHZ,
- ci.ci_mem, ci.ci_io, ci.ci_comm);
+ ci.ci_mem, ci.ci_io, ci.ci_pid, ci.ci_comm);
}
/* finally, return the file descriptor for possible truncation */