summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2013-09-22 17:28:33 +0000
committerguenther <guenther@openbsd.org>2013-09-22 17:28:33 +0000
commit447f61ceb96730e27d7a7b3aa43a220baab5f6f7 (patch)
treea78278ed5d1759c69bd4a7f35b57aeaf8f19379b /sys
parentDelete a T32 chunk that I missed before and update the comment on (diff)
downloadwireguard-openbsd-447f61ceb96730e27d7a7b3aa43a220baab5f6f7.tar.xz
wireguard-openbsd-447f61ceb96730e27d7a7b3aa43a220baab5f6f7.zip
Stop merging the per-thread and per-process flags when reporting
them via sysctl(KERN_PROC). In struct kinfo_proc the per-process flags move to p_psflags, leaving the per-thread flags in p_flags. Flag descriptions in ps(1) updated to be less obtuse. discussed with matthew@ some time ago; ok jca@, manpage bits ok jmc@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_proc.c4
-rw-r--r--sys/sys/proc.h90
-rw-r--r--sys/sys/sysctl.h8
3 files changed, 34 insertions, 68 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 1258b937742..86bb22c4dec 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_proc.c,v 1.52 2013/08/12 20:43:28 bluhm Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.53 2013/09/22 17:28:34 guenther Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
@@ -397,7 +397,7 @@ proc_printit(struct proc *p, const char *modif,
(*pr)("PROC (%s) pid=%d stat=%s\n", p->p_comm, p->p_pid, pst);
(*pr)(" flags process=%b proc=%b\n",
- p->p_p->ps_flags, P_BITS, p->p_flag, P_BITS);
+ p->p_p->ps_flags, PS_BITS, p->p_flag, P_BITS);
(*pr)(" pri=%u, usrpri=%u, nice=%d\n",
p->p_priority, p->p_usrpri, p->p_p->ps_nice);
(*pr)(" forw=%p, list=%p,%p\n",
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 92892f16501..1ea8794a796 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.169 2013/08/12 20:43:28 bluhm Exp $ */
+/* $OpenBSD: proc.h,v 1.170 2013/09/22 17:28:33 guenther Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@@ -222,30 +222,28 @@ struct process {
#endif /* __need_process */
/*
- * These flags are kept in ps_flags, but they used to be in proc's p_flag
- * and were exported to userspace via the KERN_PROC sysctl. We'll retain
- * compat by using non-overlapping bits for PS_* and P_* flags and just
- * OR them together for export.
+ * These flags are kept in ps_flags.
*/
-#define PS_CONTROLT _P_CONTROLT
-#define PS_PPWAIT _P_PPWAIT
-#define PS_PROFIL _P_PROFIL
-#define PS_SUGID _P_SUGID
-#define PS_SYSTEM _P_SYSTEM
-#define PS_TRACED _P_TRACED
-#define PS_WAITED _P_WAITED
-#define PS_EXEC _P_EXEC
-#define PS_ISPWAIT _P_ISPWAIT
-#define PS_SUGIDEXEC _P_SUGIDEXEC
-#define PS_NOZOMBIE _P_NOZOMBIE
-#define PS_INEXEC _P_INEXEC
-#define PS_SYSTRACE _P_SYSTRACE
-#define PS_CONTINUED _P_CONTINUED
-#define PS_STOPPED _P_STOPPED
-#define PS_SINGLEEXIT _P_SINGLEEXIT
-#define PS_SINGLEUNWIND _P_SINGLEUNWIND
-#define PS_EXITING _P_EXITING
-#define PS_COREDUMP _P_COREDUMP
+#define PS_CONTROLT 0x00000001 /* Has a controlling terminal. */
+#define PS_EXEC 0x00000002 /* Process called exec. */
+#define PS_INEXEC 0x00000004 /* Process is doing an exec right now */
+#define PS_EXITING 0x00000008 /* Process is exiting. */
+#define PS_SUGID 0x00000010 /* Had set id privs since last exec. */
+#define PS_SUGIDEXEC 0x00000020 /* last execve() was set[ug]id */
+#define PS_PPWAIT 0x00000040 /* Parent waits for exec/exit. */
+#define PS_ISPWAIT 0x00000080 /* Is parent of PPWAIT child. */
+#define PS_PROFIL 0x00000100 /* Has started profiling. */
+#define PS_TRACED 0x00000200 /* Being ptraced. */
+#define PS_WAITED 0x00000400 /* Stopped proc has waited for. */
+#define PS_COREDUMP 0x00000800 /* Busy coredumping */
+#define PS_SINGLEEXIT 0x00001000 /* Other threads must die. */
+#define PS_SINGLEUNWIND 0x00002000 /* Other threads must unwind. */
+
+#define PS_BITS \
+ ("\20\01CONTROLT\02EXEC\03INEXEC\04EXITING\05SUGID" \
+ "\06SUGIDEXEC\07PPWAIT\010ISPWAIT\011PROFIL\012TRACED" \
+ "\013WAITED\014COREDUMP\015SINGLEEXIT\016SINGLEUNWIND")
+
struct proc {
TAILQ_ENTRY(proc) p_runq;
@@ -361,65 +359,31 @@ struct proc {
#define P_ZOMBIE(p) ((p)->p_stat == SZOMB || (p)->p_stat == SDEAD)
/*
- * These flags are kept in p_flag, except those with a leading underbar,
- * which are in process's ps_flags
+ * These flags are per-thread and kept in p_flag
*/
#define P_INKTR 0x000001 /* In a ktrace op, don't recurse */
-#define _P_CONTROLT 0x000002 /* Has a controlling terminal. */
-#define P_INMEM 0x000004 /* Loaded into memory. UNUSED */
#define P_SIGSUSPEND 0x000008 /* Need to restore before-suspend mask*/
-#define _P_PPWAIT 0x000010 /* Parent waits for exec/exit. */
-#define _P_PROFIL 0x000020 /* Has started profiling. */
#define P_SELECT 0x000040 /* Selecting; wakeup/waiting danger. */
#define P_SINTR 0x000080 /* Sleep is interruptible. */
-#define _P_SUGID 0x000100 /* Had set id privs since last exec. */
#define P_SYSTEM 0x000200 /* No sigs, stats or swapping. */
#define P_TIMEOUT 0x000400 /* Timing out during sleep. */
-#define _P_TRACED 0x000800 /* Debugged process being traced. */
-#define _P_WAITED 0x001000 /* Debugging proc has waited for child. */
#define P_WEXIT 0x002000 /* Working on exiting. */
-#define _P_EXEC 0x004000 /* Process called exec. */
-
-/* Should be moved to machine-dependent areas. */
#define P_OWEUPC 0x008000 /* Owe proc an addupc() at next ast. */
-
-#define _P_ISPWAIT 0x010000 /* Is parent of PPWAIT child. */
-#define _P_COREDUMP 0x020000 /* busy coredumping */
-#define _P_SUGIDEXEC 0x040000 /* last execve() was set[ug]id */
#define P_SUSPSINGLE 0x080000 /* Need to stop for single threading. */
#define P_NOZOMBIE 0x100000 /* Pid 1 waits for me instead of dad */
-#define _P_INEXEC 0x200000 /* Process is doing an exec right now */
#define P_SYSTRACE 0x400000 /* Process system call tracing active*/
#define P_CONTINUED 0x800000 /* Proc has continued from a stopped state. */
-#define _P_SINGLEEXIT 0x1000000 /* Other threads must die. */
-#define _P_SINGLEUNWIND 0x2000000 /* Other threads must unwind. */
#define P_THREAD 0x4000000 /* Only a thread, not a real process */
#define P_SUSPSIG 0x8000000 /* Stopped from signal. */
#define P_SOFTDEP 0x10000000 /* Stuck processing softdep worklist */
#define P_STOPPED 0x20000000 /* Just stopped, need sig to parent. */
#define P_CPUPEG 0x40000000 /* Do not move to another cpu. */
-#define _P_EXITING 0x80000000 /* Process is exiting. */
-
-#ifndef _KERNEL
-#define P_CONTROLT _P_CONTROLT
-#define P_PPWAIT _P_PPWAIT
-#define P_PROFIL _P_PROFIL
-#define P_SUGID _P_SUGID
-#define P_TRACED _P_TRACED
-#define P_EXEC _P_EXEC
-#define P_SUGIDEXEC _P_SUGIDEXEC
-#define P_INEXEC _P_INEXEC
-#endif
#define P_BITS \
- ("\20\01INKTR\02CONTROLT\03INMEM\04SIGSUSPEND" \
- "\05PPWAIT\06PROFIL\07SELECT\010SINTR" \
- "\011SUGID\012SYSTEM\013TIMEOUT\014TRACED" \
- "\015WAITED\016WEXIT\017EXEC\020OWEUPC" \
- "\021ISPWAIT\022COREDUMP\023SUGIDEXEC\024SUSPSINGLE" \
- "\025NOZOMBIE\026INEXEC\027SYSTRACE\030CONTINUED" \
- "\031SINGLEEXIT\032SINGLEUNWIND\033THREAD\034SUSPSIG" \
- "\035SOFTDEP\036STOPPED\037CPUPEG\040EXITING")
+ ("\20\01INKTR\04SIGSUSPEND\07SELECT\010SINTR\012SYSTEM" \
+ "\013TIMEOUT\016WEXIT\020OWEUPC\024SUSPSINGLE" \
+ "\025NOZOMBIE\027SYSTRACE\030CONTINUED\033THREAD" \
+ "\034SUSPSIG\035SOFTDEP\036STOPPED\037CPUPEG")
/* Macro to compute the exit signal to be delivered. */
#define P_EXITSIG(p) \
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 2a3a129f53b..19bfee3c48e 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.137 2013/08/13 05:52:27 guenther Exp $ */
+/* $OpenBSD: sysctl.h,v 1.138 2013/09/22 17:28:33 guenther Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -423,7 +423,8 @@ struct kinfo_proc {
u_int32_t p_uctime_sec; /* STRUCT TIMEVAL: child u+s time. */
u_int32_t p_uctime_usec; /* STRUCT TIMEVAL: child u+s time. */
- u_int64_t p_realflag; /* INT: P_* flags (not including LWPs). */
+ int32_t p_psflags; /* INT: PS_* flags on the process. */
+ int32_t p_spare; /* INT: unused. */
u_int32_t p_svuid; /* UID_T: saved user id */
u_int32_t p_svgid; /* GID_T: saved group id */
char p_emul[KI_EMULNAMELEN]; /* syscall emulation name */
@@ -478,7 +479,8 @@ do { \
} \
(kp)->p_stats = 0; \
(kp)->p_exitsig = (p)->p_exitsig; \
- (kp)->p_flag = (p)->p_flag | (pr)->ps_flags | P_INMEM; \
+ (kp)->p_flag = (p)->p_flag; \
+ (kp)->p_psflags = (pr)->ps_flags; \
\
(kp)->p__pgid = (pg)->pg_id; \
\