read_proc_meminfo();
}
-- if (!interval) {
++ if (!interval && !EXEC_PGM(pidflag)) {
/* Display since boot time */
ps_tstamp[1] = ps_tstamp[0];
+ write_stats(0, DISP_HDR);
+ exit(0);
}
/* Set a handler for SIGALRM */
memset(&alrm_act, 0, sizeof(alrm_act));
alrm_act.sa_handler = alarm_handler;
sigaction(SIGALRM, &alrm_act, NULL);
- alarm(interval);
- if (interval)
++ if (interval) {
+ alarm(interval);
++ }
/* Save the first stats collected. Will be used to compute the average */
ps_tstamp[2] = ps_tstamp[0];
if (!argv[++opt]) {
usage(argv[0]);
}
-- pidflag |= P_D_PID;
++ pidflag |= P_D_PID + P_F_EXEC_PGM;
add_list_pid(&pid_list, exec_pgm(argc - opt, argv + opt), 0);
break;
}
#define P_F_PROCSTR 0x0400
#define P_D_UNIT 0x0800
#define P_D_SEC_EPOCH 0x1000
++#define P_F_EXEC_PGM 0x2000
#define DISPLAY_PID(m) (((m) & P_D_PID) == P_D_PID)
#define DISPLAY_ALL_PID(m) (((m) & P_D_ALL_PID) == P_D_ALL_PID)
#define PROCESS_STRING(m) (((m) & P_F_PROCSTR) == P_F_PROCSTR)
#define DISPLAY_UNIT(m) (((m) & P_D_UNIT) == P_D_UNIT)
#define PRINT_SEC_EPOCH(m) (((m) & P_D_SEC_EPOCH) == P_D_SEC_EPOCH)
++#define EXEC_PGM(m) (((m) & P_F_EXEC_PGM) == P_F_EXEC_PGM)
/* Per-process flags */
#define F_NO_PID_IO 0x01