Index: arch/x86/x86/syscall.c =================================================================== RCS file: /cvsroot/src/sys/arch/x86/x86/syscall.c,v retrieving revision 1.14 diff -u -r1.14 syscall.c --- arch/x86/x86/syscall.c 7 Jul 2016 06:55:40 -0000 1.14 +++ arch/x86/x86/syscall.c 28 Mar 2017 16:00:13 -0000 @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -65,22 +66,12 @@ { struct lwp *l = arg; struct trapframe *tf = l->l_md.md_regs; - struct proc *p = l->l_proc; - - if (p->p_slflag & PSL_TRACED) { - ksiginfo_t ksi; - - mutex_enter(proc_lock); - KSI_INIT_EMPTY(&ksi); - ksi.ksi_signo = SIGTRAP; - ksi.ksi_lid = l->l_lid; - kpsignal(p, &ksi, NULL); - mutex_exit(proc_lock); - } X86_TF_RAX(tf) = 0; X86_TF_RFLAGS(tf) &= ~PSL_C; + mi_child_return(l); + userret(l); ktrsysret(SYS_fork, 0, 0); } Index: sys/childreturn.h =================================================================== RCS file: sys/childreturn.h diff -N sys/childreturn.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/childreturn.h 28 Mar 2017 16:00:38 -0000 @@ -0,0 +1,59 @@ +/* $NetBSD: userret.h,v 1.26 2013/04/07 07:54:53 kiyohara Exp $ */ + +/*- + * Copyright (c) 2017 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_CHILDRETURN_H_ +#define _SYS_CHILDRETURN_H_ + +#include +#include +#include +#include + +/* + * Define the MI code for child_return + */ +static __inline void +mi_child_return(struct lwp *l) +{ + struct proc *p = l->l_proc; + + if (p->p_slflag & PSL_TRACED) { + ksiginfo_t ksi; + + KSI_INIT_EMPTY(&ksi); + ksi.ksi_signo = SIGTRAP; + ksi.ksi_code = TRAP_CHLD; + ksi.ksi_lid = l->l_lid; + + mutex_enter(proc_lock); + kpsignal(p, &ksi, NULL); + mutex_exit(proc_lock); + } +} + +#endif /* !_SYS_CHILDRETURN_H_ */