From 63c4d6030676332d662005c8750ef471df3e8bfe Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 21 Jan 2005 05:57:45 +0000 Subject: MFi386: handle PSL_T properly across fork. Typo fix. --- sys/amd64/amd64/vm_machdep.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index d784d02..9b99812 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -133,6 +134,17 @@ cpu_fork(td1, p2, td2, flags) td2->td_frame->tf_rdx = 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_rflags &= ~PSL_T; + + /* * Set registers for trampoline to user mode. Leave space for the * return address on stack. These are the kernel mode register values. */ @@ -227,7 +239,7 @@ cpu_thread_setup(struct thread *td) /* * Initialize machine state (pcb and trap frame) for a new thread about to - * upcall. Pu t enough state in the new thread's PCB to get it to go back + * upcall. Put enough state in the new thread's PCB to get it to go back * userret(), where we can intercept it again to set the return (upcall) * Address and stack, along with those from upcals that are from other sources * such as those generated in thread_userret() itself. -- cgit v1.1