If the parent process has the trap bit set (i.e. a debugger had single

stepped the process to the system call), we need to clear the trap flag
from the new frame unless the debugger had set PF_FORK on the parent.
Otherwise, the child will receive a (likely unexpected) SIGTRAP when it
executes the first instruction after returning to userland.

Reviewed by:	bde
MFC after:	3 days
This commit is contained in:
Kelly Yancey 2004-12-08 19:03:55 +00:00
parent 6f831b072a
commit 5ad5504c14
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=138592

View File

@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
#include <sys/pioctl.h>
#include <sys/proc.h>
#include <sys/sf_buf.h>
#include <sys/smp.h>
@ -194,6 +195,17 @@ cpu_fork(td1, p2, td2, flags)
td2->td_frame->tf_eflags &= ~PSL_C; /* success */
td2->td_frame->tf_edx = 1;
/*
* If the parent process has the trap bit set (i.e. a debugger had
* single stepped the process to the system call), we need to clear
* the trap flag from the new frame unless the debugger had set PF_FORK
* on the parent. Otherwise, the child will receive a (likely
* unexpected) SIGTRAP when it executes the first instruction after
* returning to userland.
*/
if ((p1->p_pfsflags & PF_FORK) == 0)
td2->td_frame->tf_eflags &= ~PSL_T;
/*
* Set registers for trampoline to user mode. Leave space for the
* return address on stack. These are the kernel mode register values.