char cmdsearch[CMDSTRSIZE];
char cmdoutput[CMDSTRSIZE];
char *task_cmdline;
- enum pids_reap_type which;
+ enum pids_fetch_type which;
preg = do_regcomp();
_("Error reading reference namespace information\n"));
}
- if (procps_pids_new(&info, 12, Items) < 0)
+ if (procps_pids_new(&info, Items, 12) < 0)
xerrx(EXIT_FATAL,
_("Unable to create pid info structure"));
+ which = PROCPS_FETCH_TASKS_ONLY;
if (opt_threads && !i_am_pkill)
- which = PROCPS_REAP_THREADS_TOO;
- else
- which = PROCPS_REAP_TASKS_ONLY;
- if (procps_pids_read_open(info, which) < 0)
- xerrx(EXIT_FATAL,
- _("Unable to open pids information"));
+ which = PROCPS_FETCH_THREADS_TOO;
- while ((stack = procps_pids_read_next(info))) {
+ while ((stack = procps_pids_get(info, which))) {
int match = 1;
if (PIDS_GETINT(PID) == myself)
}
}
}
- procps_pids_read_shut(info);
+ procps_pids_unref(&info);
*num = matches;
return list;
/* get the input base name */
program_base = get_basename(program);
- procps_pids_new(&info, 3, items);
- procps_pids_read_open(info, PROCPS_REAP_TASKS_ONLY);
+ procps_pids_new(&info, items, 3);
exe_link = root_link = NULL;
- while ((stack = procps_pids_read_next(info))) {
+ while ((stack = procps_pids_get(info, PROCPS_FETCH_TASKS_ONLY))) {
char *p_cmd = PROCPS_PIDS_VAL(rel_cmd, str, stack),
**p_cmdline = PROCPS_PIDS_VAL(rel_cmdline, strv, stack);
int tid = PROCPS_PIDS_VAL(rel_pid, s_int, stack);
}
- procps_pids_read_shut(info);
procps_pids_unref(&info);
}
int main(int argc, char **argv)
{
struct procps_pidsinfo *info = NULL;
- struct pids_reap *pids_reap;
+ struct pids_fetch *pids_fetch;
unsigned *pidlist;
int reap_count, user_count;
int ret = 0, c, conf_ret;
}
}
}
- if (procps_pids_new(&info, 4, Pid_items))
+ if (procps_pids_new(&info, Pid_items, 4))
xerrx(EXIT_FAILURE, _("library failed pids statistics"));
pidlist = xmalloc(sizeof(pid_t) * argc);
discover_shm_minor();
- if (!(pids_reap = procps_pids_select(info, pidlist, user_count, PROCPS_SELECT_PID)))
+ if (!(pids_fetch = procps_pids_select(info, pidlist, user_count, PROCPS_SELECT_PID)))
xerrx(EXIT_FAILURE, _("library failed pids statistics"));
- for (reap_count = 0; reap_count < pids_reap->counts.total; reap_count++) {
- ret |= one_proc(pids_reap->stacks[reap_count]);
+ for (reap_count = 0; reap_count < pids_fetch->counts.total; reap_count++) {
+ ret |= one_proc(pids_fetch->stacks[reap_count]);
}
free(pidlist);
makEXT(TTY_NAME)
makEXT(TTY_NUMBER)
makEXT(VM_DATA)
-makEXT(VM_LOCK)
+makEXT(VM_RSS_LOCKED)
makEXT(VM_RSS)
makEXT(VM_SIZE)
makEXT(VM_STACK)
/***** just display */
static void simple_spew(void){
- struct pids_reap *pidreap;
+ struct pids_fetch *pidread;
proc_t *buf;
int i;
unsigned *pidlist = xcalloc(selection_list->n, sizeof(unsigned));
for (i = 0; i < selection_list->n; i++)
pidlist[i] = selection_list->u[selection_list->n-i-1].pid;
- pidreap = procps_pids_select(Pids_info, pidlist, selection_list->n, PROCPS_SELECT_PID);
+ pidread = procps_pids_select(Pids_info, pidlist, selection_list->n, PROCPS_SELECT_PID);
free(pidlist);
} else {
- enum pids_reap_type which;
+ enum pids_fetch_type which;
which = (thread_flags & (TF_loose_tasks|TF_show_task))
- ? PROCPS_REAP_THREADS_TOO : PROCPS_REAP_TASKS_ONLY;
- pidreap = procps_pids_reap(Pids_info, which);
+ ? PROCPS_FETCH_THREADS_TOO : PROCPS_FETCH_TASKS_ONLY;
+ pidread = procps_pids_reap(Pids_info, which);
}
- if (!pidreap) {
+ if (!pidread) {
fprintf(stderr, _("fatal library error, reap\n"));
exit(EXIT_FAILURE);
}
switch(thread_flags & (TF_show_proc|TF_loose_tasks|TF_show_task)){
case TF_show_proc: // normal non-thread output
- for (i = 0; i < pidreap->counts.total; i++) {
- buf = pidreap->stacks[i];
+ for (i = 0; i < pidread->counts.total; i++) {
+ buf = pidread->stacks[i];
if (want_this_proc(buf))
show_one_proc(buf, proc_format_list);
}
break;
case TF_show_task: // -L and -T options
case TF_show_proc|TF_loose_tasks: // H option
- for (i = 0; i < pidreap->counts.total; i++) {
- buf = pidreap->stacks[i];
+ for (i = 0; i < pidread->counts.total; i++) {
+ buf = pidread->stacks[i];
if (want_this_proc(buf))
show_one_proc(buf, task_format_list);
}
break;
case TF_show_proc|TF_show_task: // m and -m options
- procps_pids_sort(Pids_info, pidreap->stacks
- , pidreap->counts.total, PROCPS_PIDS_TIME_START, PROCPS_SORT_ASCEND);
- procps_pids_sort(Pids_info, pidreap->stacks
- , pidreap->counts.total, PROCPS_PIDS_ID_TGID, PROCPS_SORT_ASCEND);
- for (i = 0; i < pidreap->counts.total; i++) {
- buf = pidreap->stacks[i];
+ procps_pids_sort(Pids_info, pidread->stacks
+ , pidread->counts.total, PROCPS_PIDS_TIME_START, PROCPS_SORT_ASCEND);
+ procps_pids_sort(Pids_info, pidread->stacks
+ , pidread->counts.total, PROCPS_PIDS_ID_TGID, PROCPS_SORT_ASCEND);
+ for (i = 0; i < pidread->counts.total; i++) {
+ buf = pidread->stacks[i];
next_proc:
if (want_this_proc(buf)) {
int self = rSv(ID_PID, s_int, buf);
show_one_proc(buf, proc_format_list);
- for (; i < pidreap->counts.total; i++) {
- buf = pidreap->stacks[i];
+ for (; i < pidread->counts.total; i++) {
+ buf = pidread->stacks[i];
if (rSv(ID_TGID, s_int, buf) != self) goto next_proc;
show_one_proc(buf, task_format_list);
}
/***** sorted or forest */
static void fancy_spew(void){
- struct pids_reap *pidreap;
- enum pids_reap_type which;
+ struct pids_fetch *pidread;
+ enum pids_fetch_type which;
proc_t *buf;
int i, n = 0;
which = (thread_flags & TF_loose_tasks)
- ? PROCPS_REAP_THREADS_TOO : PROCPS_REAP_TASKS_ONLY;
+ ? PROCPS_FETCH_THREADS_TOO : PROCPS_FETCH_TASKS_ONLY;
- pidreap = procps_pids_reap(Pids_info, which);
- if (!pidreap || !pidreap->counts.total) {
+ pidread = procps_pids_reap(Pids_info, which);
+ if (!pidread || !pidread->counts.total) {
fprintf(stderr, _("fatal library error, reap\n"));
exit(EXIT_FAILURE);
}
- processes = xcalloc(pidreap->counts.total, sizeof(void*));
- for (i = 0; i < pidreap->counts.total; i++) {
- buf = pidreap->stacks[i];
+ processes = xcalloc(pidread->counts.total, sizeof(void*));
+ for (i = 0; i < pidread->counts.total; i++) {
+ buf = pidread->stacks[i];
value_this_proc_pcpu(buf);
if (want_this_proc(buf))
processes[n++] = buf;
chkREL(NICE)
chkREL(NLWP)
chkREL(RSS)
- chkREL(VM_LOCK)
+ chkREL(VM_RSS_LOCKED)
// needed with 's' switch, previously assured
chkREL(SIGBLOCKED)
chkREL(SIGCATCH)
s_node = s_node->next;
}
- procps_pids_reset(Pids_info, Pids_index, Pids_items);
+ procps_pids_reset(Pids_info, Pids_items, Pids_index);
}
/***** no comment */
makREL(TTY_NAME)
makREL(TTY_NUMBER)
makREL(VM_DATA)
-makREL(VM_LOCK)
+makREL(VM_RSS_LOCKED)
makREL(VM_RSS)
makREL(VM_SIZE)
makREL(VM_STACK)
Pids_items[i] = PROCPS_PIDS_noop;
if (!Pids_info) {
- if (procps_pids_new(&Pids_info, i, Pids_items)) {
+ if (procps_pids_new(&Pids_info, Pids_items, i)) {
fprintf(stderr, _("fatal library error, context\n"));
exit(EXIT_FAILURE);
}
}
Pids_items[0] = PROCPS_PIDS_TTY;
- procps_pids_reset(Pids_info, 1, Pids_items);
+ procps_pids_reset(Pids_info, Pids_items, 1);
if (!(p = fatal_proc_unmounted(Pids_info, 1))) {
fprintf(stderr, _("fatal library error, lookup self\n"));
exit(EXIT_FAILURE);
if (!outbuf) {
chkREL(STATE)
chkREL(NICE)
- chkREL(VM_LOCK)
+ chkREL(VM_RSS_LOCKED)
chkREL(ID_SESSION)
chkREL(ID_TGID)
chkREL(NLWP)
// exiting 'E' (not printed for zombies)
// vforked 'V'
// system 'K' (and do not print 'L' too)
- if(rSv(VM_LOCK, ul_int, pp)) outbuf[end++] = 'L';
+ if(rSv(VM_RSS_LOCKED, sl_int, pp)) outbuf[end++] = 'L';
if(rSv(ID_SESSION, s_int, pp) == rSv(ID_TGID, s_int, pp)) outbuf[end++] = 's'; // session leader
if(rSv(NLWP, s_int, pp) > 1) outbuf[end++] = 'l'; // multi-threaded
if(rSv(ID_PGRP, s_int, pp) == rSv(ID_TPGID, s_int, pp)) outbuf[end++] = '+'; // in foreground process group
{"vm_data", "DATA", pr_nop, PROCPS_PIDS_VM_DATA, 5, LNx, PO|RIGHT},
{"vm_exe", "EXE", pr_nop, PROCPS_PIDS_VM_EXE, 5, LNx, PO|RIGHT},
{"vm_lib", "LIB", pr_nop, PROCPS_PIDS_VM_LIB, 5, LNx, PO|RIGHT},
-{"vm_lock", "LCK", pr_nop, PROCPS_PIDS_VM_LOCK, 3, LNx, PO|RIGHT},
+{"vm_lock", "LCK", pr_nop, PROCPS_PIDS_VM_RSS_LOCKED, 3, LNx, PO|RIGHT},
{"vm_stack", "STACK", pr_nop, PROCPS_PIDS_VM_STACK, 5, LNx, PO|RIGHT},
{"vsize", "VSZ", pr_vsz, PROCPS_PIDS_VSIZE_PGS, 6, DEC, PO|RIGHT}, /*vsz*/
{"vsz", "VSZ", pr_vsz, PROCPS_PIDS_VM_SIZE, 6, U98, PO|RIGHT}, /*vsize*/
if (procps_pids_new(&info, 6, items) < 0)
xerrx(EXIT_FAILURE,
_("Unable to create pid info structure"));
- if ((reap = procps_pids_reap(info, PROCPS_REAP_TASKS_ONLY)) == NULL)
+ if ((reap = procps_pids_reap(info, PROCPS_FETCH_TASKS_ONLY)) == NULL)
xerrx(EXIT_FAILURE,
_("Unable to load process information"));
static int Batch = 0, // batch mode, collect no input, dumb output
Loops = -1, // number of iterations, -1 loops forever
Secure_mode = 0, // set if some functionality restricted
- Width_mode = 0; // set w/ 'w' - potential output override
-enum pids_reap_type
+ Width_mode = 0, // set w/ 'w' - potential output override
Thread_mode = 0; // set w/ 'H' - show threads vs. tasks
/* Unchangeable cap's stuff built just once (if at all) and
static struct procps_pidsinfo *Pids_ctx;
static int Pids_itms_cur; // 'current' max (<= Fieldstab)
static enum pids_item *Pids_itms; // allocated as MAXTBL(Fieldstab)
-static struct pids_reap *Pids_reap; // for reap or select
-#define PIDSmaxt Pids_reap->counts.total // just a little less wordy
+static struct pids_fetch *Pids_read; // for reap or select
+#define PIDSmaxt Pids_read->counts.total // just a little less wordy
// pid stack results extractor macro, where e=our EU enum, t=type, s=stack
// ( we'll exploit that <proc/pids.h> provided macro as much as possible )
// ( but many functions use their own unique tailored version for access )
build_headers();
- if (procps_pids_reset(Pids_ctx, Pids_itms_cur, Pids_itms))
+ if (procps_pids_reset(Pids_ctx, Pids_itms, Pids_itms_cur))
error_exit(fmtmk(N_fmt(LIB_errorpid_fmt),__LINE__));
if (CHKw(Curwin, View_SCROLL))
static void procs_refresh (void) {
#define nALIGN(n,m) (((n + m - 1) / m) * m) // unconditionally align
#define nALGN2(n,m) ((n + m - 1) & ~(m - 1)) // with power of 2 align
- #define n_reap Pids_reap->counts.total
+ #define n_reap Pids_read->counts.total
static double uptime_sav;
static int n_alloc = -1; // size of windows stacks arrays
double uptime_cur;
// if in Solaris mode, adjust our scaling for all cpus
Frame_etscale = 100.0f / ((float)Hertz * (float)et * (Rc.mode_irixps ? 1 : Cpu_cnt));
- if (!Monpidsidx) Pids_reap = procps_pids_reap(Pids_ctx, Thread_mode);
- else Pids_reap = procps_pids_select(Pids_ctx, Monpids, Monpidsidx, PROCPS_SELECT_PID);
- if (!Pids_reap)
+ if (Monpidsidx) Pids_read = procps_pids_select(Pids_ctx, Monpids, Monpidsidx, PROCPS_SELECT_PID);
+ else Pids_read = procps_pids_reap(Pids_ctx, Thread_mode ? PROCPS_FETCH_THREADS_TOO : PROCPS_FETCH_TASKS_ONLY);
+ if (!Pids_read)
error_exit(fmtmk(N_fmt(LIB_errorpid_fmt),__LINE__));
// now refresh each window's stack heads pointers table...
n_alloc = nALGN2(n_reap, 128);
for (i = 0; i < GROUPSMAX; i++) {
Winstk[i].ppt = alloc_r(Winstk[i].ppt, sizeof(void*) * n_alloc);
- memcpy(Winstk[i].ppt, Pids_reap->stacks, sizeof(void*) * PIDSmaxt);
+ memcpy(Winstk[i].ppt, Pids_read->stacks, sizeof(void*) * PIDSmaxt);
}
} else {
for (i = 0; i < GROUPSMAX; i++)
- memcpy(Winstk[i].ppt, Pids_reap->stacks, sizeof(void*) * PIDSmaxt);
+ memcpy(Winstk[i].ppt, Pids_read->stacks, sizeof(void*) * PIDSmaxt);
}
#undef n_reap
#undef nALGN2
Pids_itms[i] = PROCPS_PIDS_noop;
Pids_itms_cur = i;
// we will identify specific items in the build_headers() function
- if (procps_pids_new(&Pids_ctx, Pids_itms_cur, Pids_itms))
+ if (procps_pids_new(&Pids_ctx, Pids_itms, Pids_itms_cur))
error_exit(fmtmk(N_fmt(LIB_errorpid_fmt),__LINE__));
#ifndef SIGRTMAX // not available on hurd, maybe others too
if (isROOM(View_STATES, 2)) {
show_special(0, fmtmk(N_unq(STATE_line_1_fmt)
, Thread_mode ? N_txt(WORD_threads_txt) : N_txt(WORD_process_txt)
- , PIDSmaxt, Pids_reap->counts.running, Pids_reap->counts.sleeping
- , Pids_reap->counts.stopped, Pids_reap->counts.zombied));
+ , PIDSmaxt, Pids_read->counts.running, Pids_read->counts.sleeping
+ , Pids_read->counts.stopped, Pids_read->counts.zombied));
Msg_row += 1;
cpus_refresh();
unsigned long long secondbest_time = 0;
struct procps_pidsinfo *info=NULL;
- struct pids_reap *reap;
+ struct pids_fetch *reap;
enum pids_item items[] = {
PROCPS_PIDS_ID_TGID,
PROCPS_PIDS_TIME_START,
line = get_tty_device(tty);
- if (procps_pids_new(&info, 9, items) < 0)
+ if (procps_pids_new(&info, items, 9) < 0)
xerrx(EXIT_FAILURE,
_("Unable to create pid info structure"));
- if ((reap = procps_pids_reap(info, PROCPS_REAP_TASKS_ONLY)) == NULL)
+ if ((reap = procps_pids_reap(info, PROCPS_FETCH_TASKS_ONLY)) == NULL)
xerrx(EXIT_FAILURE,
_("Unable to load process information"));
total_procs = reap->counts.total;