Index: sys/sys/proc.h =================================================================== --- sys/sys/proc.h (wersja 244122) +++ sys/sys/proc.h (kopia robocza) @@ -655,6 +655,9 @@ #define P_MAGIC 0xbeefface +#define BSD_PID_MAX 99999 +#define BSD_NO_PID (BSD_PID_MAX + 1) + #ifdef _KERNEL /* Types and flags for mi_switch(). */ @@ -701,8 +704,8 @@ * We use process IDs <= pid_max <= PID_MAX; PID_MAX + 1 must also fit * in a pid_t, as it is used to represent "no process group". */ -#define PID_MAX 99999 -#define NO_PID 100000 +#define PID_MAX BSD_PID_MAX +#define NO_PID BSD_NO_PID extern pid_t pid_max; #define SESS_LEADER(p) ((p)->p_session->s_leader == (p)) Index: bin/ps/ps.c =================================================================== --- bin/ps/ps.c (wersja 244154) +++ bin/ps/ps.c (kopia robocza) @@ -109,7 +109,6 @@ static int needenv; /* -e */ static int needuser; /* -o "user" */ static int optfatal; /* Fatal error parsing some list-option. */ -static int pid_max; /* kern.max_pid */ static enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT; @@ -743,7 +742,7 @@ if (*endp != '\0' || tempid < 0 || elem == endp) { warnx("Invalid %s: %s", inf->lname, elem); errno = ERANGE; - } else if (errno != 0 || tempid > pid_max) { + } else if (errno != 0 || tempid > BSD_PID_MAX) { warnx("%s too large: %s", inf->lname, elem); errno = ERANGE; } @@ -1354,18 +1353,6 @@ } static void -pidmax_init(void) -{ - size_t intsize; - - intsize = sizeof(pid_max); - if (sysctlbyname("kern.pid_max", &pid_max, &intsize, NULL, 0) < 0) { - warn("unable to read kern.pid_max"); - pid_max = 99999; - } -} - -static void usage(void) { #define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]" Index: usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c =================================================================== --- usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c (wersja 243991) +++ usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c (kopia robocza) @@ -47,11 +47,6 @@ #include "hostres_oid.h" #include "hostres_tree.h" -/* - * Ugly thing: PID_MAX, NO_PID defined only in kernel - */ -#define NO_PID 100000 - enum SWRunType { SRT_UNKNOWN = 1, SRT_OPERATING_SYSTEM = 2, @@ -372,13 +367,14 @@ /* * kernel and kernel files (*.ko) will be indexed starting with - * NO_PID + 1; NO_PID is PID_MAX + 1 thus it will be no risk to - * overlap with real PIDs which are in range of 1 .. NO_PID + * BSD_NO_PID + 1; NO_PID is PID_MAX + 1 thus it will be no risk + * to overlap with real PIDs which are in range of + * 1 .. BSD_NO_PID */ - entry = swrun_entry_find_by_index(NO_PID + 1 + stat.id); + entry = swrun_entry_find_by_index(BSD_NO_PID + 1 + stat.id); if (entry == NULL) { /* new entry - get memory for it */ - entry = swrun_entry_create(NO_PID + 1 + stat.id); + entry = swrun_entry_create(BSD_NO_PID + 1 + stat.id); if (entry == NULL) continue; } @@ -433,21 +429,21 @@ assert(entry != NULL); - if (entry->index >= NO_PID + 1) { + if (entry->index >= BSD_NO_PID + 1) { /* * kernel and kernel files (*.ko) will be indexed - * starting with NO_PID + 1; NO_PID is PID_MAX + 1 + * starting with BSD_NO_PID + 1; BSD_NO_PID is BSD_PID_MAX + 1 * thus it will be no risk to overlap with real PIDs - * which are in range of 1 .. NO_PID + * which are in range of 1 .. BSD_NO_PID */ stat.version = sizeof(stat); - if (kldstat(entry->index - NO_PID - 1, &stat) == -1) { + if (kldstat(entry->index - BSD_NO_PID - 1, &stat) == -1) { /* * not found, it's gone. Mark it as invalid for now, it * will be removed from the list at next global refersh */ HRDBG("missing item with kid=%d", - entry->index - NO_PID - 1); + entry->index - BSD_NO_PID - 1); entry->status = (int32_t)SRS_INVALID; } else kld_file_stat_to_swrun(&stat, entry); @@ -477,10 +473,10 @@ assert(entry != NULL); - if (entry->index >= NO_PID + 1) { + if (entry->index >= BSD_NO_PID + 1) { /* this is a kernel item */ HRDBG("atempt to unload KLD %d", - entry->index - NO_PID - 1); + entry->index - BSD_NO_PID - 1); if (entry->index == SWOSIndex) { /* can't invalidate the kernel itself */ @@ -488,14 +484,14 @@ } stat.version = sizeof(stat); - if (kldstat(entry->index - NO_PID - 1, &stat) == -1) { + if (kldstat(entry->index - BSD_NO_PID - 1, &stat) == -1) { /* * not found, it's gone. Mark it as invalid for now, it * will be removed from the list at next global * refresh */ HRDBG("missing item with kid=%d", - entry->index - NO_PID - 1); + entry->index - BSD_NO_PID - 1); entry->status = (int32_t)SRS_INVALID; return (SNMP_ERR_NOERROR); }