1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-25 14:45:52 +00:00

Delete tests for P_THREAD that predate the existence of

KERN_PROC_SHOW_THREADS and have been rendered superfluous by it.
Similarly, some P_SYSTEM tests can be deleted or pushed to the
kernel by using KERN_PROC_ALL instead of KERN_PROC_KTHREAD.

ok visa@ mpi@
This commit is contained in:
guenther
2019-12-16 19:21:16 +00:00
parent 616241480a
commit 0f1976c81e
3 changed files with 21 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: ps.c,v 1.75 2019/03/24 05:30:35 deraadt Exp $ */
/* $OpenBSD: ps.c,v 1.76 2019/12/16 19:21:16 guenther Exp $ */
/* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */
/*-
@@ -361,8 +361,6 @@ main(int argc, char *argv[])
* for each proc, call each variable output function.
*/
for (i = lineno = 0; i < nentries; i++) {
if (showthreads == 0 && (kinfo[i]->p_flag & P_THREAD) != 0)
continue;
if (xflg == 0 && ((int)kinfo[i]->p_tdev == NODEV ||
(kinfo[i]->p_psflags & PS_CONTROLT ) == 0))
continue;

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: pkill.c,v 1.41 2019/06/28 13:35:02 deraadt Exp $ */
/* $OpenBSD: pkill.c,v 1.42 2019/12/16 19:21:17 guenther Exp $ */
/* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */
/*-
@@ -297,8 +297,7 @@ main(int argc, char **argv)
}
for (i = 0, kp = plist; i < nproc; i++, kp++) {
if ((kp->p_flag & (P_SYSTEM | P_THREAD)) != 0 ||
kp->p_pid == mypid)
if (kp->p_pid == mypid)
continue;
if (matchargs)
@@ -324,8 +323,7 @@ main(int argc, char **argv)
}
for (i = 0, kp = plist; i < nproc; i++, kp++) {
if ((kp->p_flag & (P_SYSTEM | P_THREAD)) != 0 ||
kp->p_pid == mypid)
if (kp->p_pid == mypid)
continue;
SLIST_FOREACH(li, &ruidlist, li_chain)
@@ -435,8 +433,7 @@ main(int argc, char **argv)
*/
rv = STATUS_NOMATCH;
for (i = 0, j = 0, kp = plist; i < nproc; i++, kp++) {
if ((kp->p_flag & (P_SYSTEM | P_THREAD)) != 0 ||
kp->p_pid == mypid)
if (kp->p_pid == mypid)
continue;
if (selected[i] == inverse)
continue;

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: machine.c,v 1.100 2019/10/08 20:51:03 kn Exp $ */
/* $OpenBSD: machine.c,v 1.101 2019/12/16 19:21:17 guenther Exp $ */
/*-
* Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com>
@@ -427,9 +427,14 @@ get_process_info(struct system_info *si, struct process_select *sel,
int hide_uid;
int total_procs, active_procs;
struct kinfo_proc **prefp, *pp;
int what = KERN_PROC_KTHREAD;
int what = KERN_PROC_ALL;
if (sel->threads)
show_system = sel->system;
show_threads = sel->threads;
if (show_system)
what = KERN_PROC_KTHREAD;
if (show_threads)
what |= KERN_PROC_SHOW_THREADS;
if ((pbase = getprocs(what, 0, &nproc)) == NULL) {
@@ -448,8 +453,6 @@ get_process_info(struct system_info *si, struct process_select *sel,
/* set up flags which define what we are going to select */
show_idle = sel->idle;
show_system = sel->system;
show_threads = sel->threads;
show_uid = sel->uid != (uid_t)-1;
hide_uid = sel->huid != (uid_t)-1;
show_pid = sel->pid != (pid_t)-1;
@@ -462,16 +465,17 @@ get_process_info(struct system_info *si, struct process_select *sel,
prefp = pref;
for (pp = pbase; pp < &pbase[nproc]; pp++) {
/*
* Place pointers to each valid proc structure in pref[].
* Process slots that are actually in use have a non-zero
* status field. Processes with P_SYSTEM set are system
* processes---these get ignored unless show_system is set.
* When showing threads, we want to ignore the structure
* that represents the entire process, which has TID == -1
*/
if (show_threads && pp->p_tid == -1)
continue;
if (pp->p_stat != 0 &&
(show_system || (pp->p_flag & P_SYSTEM) == 0) &&
(show_threads || (pp->p_flag & P_THREAD) == 0)) {
/*
* Place pointers to each valid proc structure in pref[].
* Process slots that are actually in use have a non-zero
* status field.
*/
if (pp->p_stat != 0) {
total_procs++;
process_states[(unsigned char) pp->p_stat]++;
if ((pp->p_psflags & PS_ZOMBIE) == 0 &&