mirror of
https://github.com/opnsense/src.git
synced 2026-04-29 10:11:09 -04:00
Add a knob to disable dequeueing SIGCHLD on waiting for live process
It seems that Linux does not dequeue siginfo for SIGCHLD when wait*(2) reports status of the running process. In particular, sigwaitinfo(2) and other signal querying syscalls can observe the siginfo after wait. FreeBSD dequeued siginfo from the beginning, so we cannot change the default ABI to be more compatible. Still, add a knob to enable to change to the other behavior for debugging purposes. Reported by: dchagin Reviewed by: dchagin, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30675
This commit is contained in:
parent
bc38762474
commit
a12e901a5a
2 changed files with 12 additions and 3 deletions
|
|
@ -105,6 +105,11 @@ SYSCTL_INT(_kern, OID_AUTO, kill_on_debugger_exit, CTLFLAG_RWTUN,
|
|||
&kern_kill_on_dbg_exit, 0,
|
||||
"Kill ptraced processes when debugger exits");
|
||||
|
||||
static bool kern_wait_dequeue_sigchld = 1;
|
||||
SYSCTL_BOOL(_kern, OID_AUTO, wait_dequeue_sigchld, CTLFLAG_RWTUN,
|
||||
&kern_wait_dequeue_sigchld, 0,
|
||||
"Dequeue SIGCHLD on wait(2) for live process");
|
||||
|
||||
struct proc *
|
||||
proc_realparent(struct proc *child)
|
||||
{
|
||||
|
|
@ -1207,9 +1212,12 @@ report_alive_proc(struct thread *td, struct proc *p, siginfo_t *siginfo,
|
|||
p->p_flag &= ~P_CONTINUED;
|
||||
else
|
||||
p->p_flag |= P_WAITED;
|
||||
PROC_LOCK(td->td_proc);
|
||||
sigqueue_take(p->p_ksi);
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
if (kern_wait_dequeue_sigchld &&
|
||||
(td->td_proc->p_sysent->sv_flags & SV_SIG_WAITNDQ) == 0) {
|
||||
PROC_LOCK(td->td_proc);
|
||||
sigqueue_take(p->p_ksi);
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
}
|
||||
}
|
||||
sx_xunlock(&proctree_lock);
|
||||
if (siginfo != NULL) {
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ struct sysentvec {
|
|||
#define SV_ASLR 0x080000 /* ASLR allowed. */
|
||||
#define SV_RNG_SEED_VER 0x100000 /* random(4) reseed generation. */
|
||||
#define SV_SIG_DISCIGN 0x200000 /* Do not discard ignored signals */
|
||||
#define SV_SIG_WAITNDQ 0x400000 /* Wait does not dequeue SIGCHLD */
|
||||
|
||||
#define SV_ABI_MASK 0xff
|
||||
#define SV_PROC_FLAG(p, x) ((p)->p_sysent->sv_flags & (x))
|
||||
|
|
|
|||
Loading…
Reference in a new issue