1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

Mark processes that are stopped because of a ptrace trap as PS_TRAPPED.

Use this flag instead of ps_single in dowait6() to decide if a process
was stopped because of a ptrace event.
OK mpi@
This commit is contained in:
claudio 2024-12-17 14:45:00 +00:00
parent 395f60ac68
commit 0c9ac8635e
3 changed files with 14 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_exit.c,v 1.239 2024/10/15 13:49:26 claudio Exp $ */
/* $OpenBSD: kern_exit.c,v 1.240 2024/12/17 14:45:00 claudio Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@ -543,10 +543,9 @@ loop:
proc_finish_wait(q, pr);
return (0);
}
if ((options & WTRAPPED) &&
(pr->ps_flags & PS_TRACED) &&
(pr->ps_flags & PS_WAITED) == 0 && pr->ps_single &&
pr->ps_single->p_stat == SSTOP) {
if ((options & WTRAPPED) && (pr->ps_flags & PS_TRACED) &&
(pr->ps_flags & PS_WAITED) == 0 &&
(pr->ps_flags & PS_TRAPPED)) {
if (single_thread_wait(pr, 0))
goto loop;
@ -570,7 +569,8 @@ loop:
}
if (((pr->ps_flags & PS_TRACED) || (options & WUNTRACED)) &&
(pr->ps_flags & PS_WAITED) == 0 &&
(pr->ps_flags & PS_STOPPED)) {
(pr->ps_flags & PS_STOPPED) &&
(pr->ps_flags & PS_TRAPPED) == 0) {
if ((options & WNOWAIT) == 0)
atomic_setbits_int(&pr->ps_flags, PS_WAITED);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sig.c,v 1.352 2024/11/24 12:58:06 claudio Exp $ */
/* $OpenBSD: kern_sig.c,v 1.353 2024/12/17 14:45:00 claudio Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@ -1103,7 +1103,7 @@ ptsignal_locked(struct proc *p, int signum, enum signal_type type)
*/
atomic_setbits_int(&pr->ps_flags, PS_CONTINUED);
atomic_clearbits_int(&pr->ps_flags,
PS_WAITED | PS_STOPPED);
PS_WAITED | PS_STOPPED | PS_TRAPPED);
atomic_clearbits_int(&p->p_flag, P_SUSPSIG);
wakeparent = 1;
if (action == SIG_DFL)
@ -1500,7 +1500,10 @@ proc_trap(struct proc *p, int signum)
pr->ps_xsig = signum;
SCHED_LOCK();
atomic_setbits_int(&pr->ps_flags, PS_TRAPPED);
proc_stop(p, 1);
atomic_clearbits_int(&pr->ps_flags,
PS_WAITED | PS_STOPPED | PS_TRAPPED);
SCHED_UNLOCK();
signum = pr->ps_xsig;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.h,v 1.376 2024/10/22 11:54:05 claudio Exp $ */
/* $OpenBSD: proc.h,v 1.377 2024/12/17 14:45:00 claudio Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@ -305,6 +305,7 @@ struct process {
#define PS_ITIMER 0x04000000 /* Virtual interval timers running */
#define PS_CONTINUED 0x20000000 /* Continued proc not yet waited for */
#define PS_STOPPED 0x40000000 /* Stopped process */
#define PS_TRAPPED 0x80000000 /* Stopped due to tracing event */
#define PS_BITS \
("\20" "\01CONTROLT" "\02EXEC" "\03INEXEC" "\04EXITING" "\05SUGID" \
@ -313,7 +314,7 @@ struct process {
"\017NOZOMBIE" "\020STOPPING" "\021SYSTEM" "\022EMBRYO" "\023ZOMBIE" \
"\024NOBROADCASTKILL" "\025PLEDGE" "\026WXNEEDED" "\027EXECPLEDGE" \
"\030ORPHAN" "\031CHROOT" "\032NOBTCFI" "\033ITIMER" "\036CONTINUED" \
"\037STOPPED")
"\037STOPPED" "\040TRAPPED")
struct kcov_dev;
struct lock_list_entry;