ptg10805159Section 8.14 Process Accounting 271
FreeBSD Linux Mac OS X Solaris
ac_flag Description 8.0 3.2.0 10.6.8 10AFORK process is the result offork,but never calledexec ••••
ASU process used superuser privileges •••
ACORE process dumped core•••
AXSIG process was killed by a signal •••
AEXPND expanded accounting entry •
ANVER new recordformat •Figure 8.26Values forac_flagfrom accounting recordexecs B, then Bexecs C, and Cexits—only a single accounting record is written.
The command name in the recordcorresponds to program C, but the CPU times, for
example, arethe sum for programs A, B, and C.Example
To have some accounting data to examine, we’ll create a test program to implement the
diagram shown in Figure8.27.sleep( 2 )
exit( 2 )
sleep( 4 )
abort()sleep( 8 )
exit( 0 )
sleep( 6 )
kill()parent
first child
second child
thirdchild
fourth child/bin/ddfork
fork
fork
forkexeclFigure 8.27 Process structurefor accounting exampleThe source for the test program is shown in Figure8.28. It callsforkfour times. Each
child does something different and then terminates.
#include "apue.h"
int
main(void)
{
pid_t pid;
if ((pid = fork()) < 0)
err_sys("fork error");