man.bsd.lv manual page server

Manual Page Search Parameters

PROC_COMPARE(3) Library Functions Manual PROC_COMPARE(3)

proc_comparecompare two processes' interactivity

library “libutil”

#include <sys/sysctl.h>

int
proc_compare(const struct kinfo_proc2 *p1, const struct kinfo_lwp *l1, const struct kinfo_proc2 *p2, const struct kinfo_lwp *l2);

The () function compares two processes that are on the same terminal for their interactivity. This means that the process returned is the one that has a better chance being the active foreground process on that tty. This algorithm is used in the kernel for SIGINFO reporting and in userland by w(1).

The algorithm used is as follows:

In all cases where the most recently started wins, if there was no winner, the one with the largest PID wins.

The proc_compare() function returns 0 if p1 is to be preferred and 1 if p2 is to be preferred.

w(1)

The proc_compare() was extracted from src/sys/kern/tty.c and src/usr.bin/w/proc_compare.c and merged in NetBSD 6.0.

October 20, 2011 NetBSD-9.2