kern_exit_43.c revision 1.18.4.1
11.18.4.1Smjf/* $NetBSD: kern_exit_43.c,v 1.18.4.1 2007/07/11 20:03:47 mjf Exp $ */ 21.1Schristos 31.1Schristos/* 41.1Schristos * Copyright (c) 1982, 1986, 1989, 1991, 1993 51.1Schristos * The Regents of the University of California. All rights reserved. 61.1Schristos * (c) UNIX System Laboratories, Inc. 71.1Schristos * All or some portions of this file are derived from material licensed 81.1Schristos * to the University of California by American Telephone and Telegraph 91.1Schristos * Co. or Unix System Laboratories, Inc. and are reproduced herein with 101.1Schristos * the permission of UNIX System Laboratories, Inc. 111.1Schristos * 121.1Schristos * Redistribution and use in source and binary forms, with or without 131.1Schristos * modification, are permitted provided that the following conditions 141.1Schristos * are met: 151.1Schristos * 1. Redistributions of source code must retain the above copyright 161.1Schristos * notice, this list of conditions and the following disclaimer. 171.1Schristos * 2. Redistributions in binary form must reproduce the above copyright 181.1Schristos * notice, this list of conditions and the following disclaimer in the 191.1Schristos * documentation and/or other materials provided with the distribution. 201.11Sagc * 3. Neither the name of the University nor the names of its contributors 211.1Schristos * may be used to endorse or promote products derived from this software 221.1Schristos * without specific prior written permission. 231.1Schristos * 241.1Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251.1Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261.1Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271.1Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281.1Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291.1Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301.1Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311.1Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321.1Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331.1Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341.1Schristos * SUCH DAMAGE. 351.1Schristos * 361.1Schristos * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 371.1Schristos */ 381.7Slukem 391.7Slukem#include <sys/cdefs.h> 401.18.4.1Smjf__KERNEL_RCSID(0, "$NetBSD: kern_exit_43.c,v 1.18.4.1 2007/07/11 20:03:47 mjf Exp $"); 411.1Schristos 421.1Schristos#include <sys/param.h> 431.1Schristos#include <sys/systm.h> 441.1Schristos#include <sys/ioctl.h> 451.1Schristos#include <sys/proc.h> 461.1Schristos#include <sys/tty.h> 471.1Schristos#include <sys/time.h> 481.1Schristos#include <sys/resource.h> 491.1Schristos#include <sys/kernel.h> 501.1Schristos#include <sys/buf.h> 511.1Schristos#include <sys/wait.h> 521.1Schristos#include <sys/file.h> 531.1Schristos#include <sys/vnode.h> 541.1Schristos#include <sys/syslog.h> 551.1Schristos#include <sys/resourcevar.h> 561.1Schristos#include <sys/ptrace.h> 571.1Schristos#include <sys/acct.h> 581.1Schristos 591.1Schristos#include <sys/mount.h> 601.1Schristos#include <sys/syscallargs.h> 611.1Schristos 621.1Schristos#include <machine/cpu.h> 631.1Schristos#include <machine/reg.h> 641.1Schristos#include <compat/common/compat_util.h> 651.5Smrg 661.1Schristos#ifdef m68k 671.4Sjonathan#include <machine/psl.h> /* only m68k ports use PSL_ALLCC */ 681.1Schristos#include <machine/frame.h> 691.1Schristos#define GETPS(rp) ((struct frame *)(rp))->f_sr 701.1Schristos#else 711.1Schristos#define GETPS(rp) (rp)[PS] 721.1Schristos#endif 731.1Schristos 741.1Schristosint 751.15Schristoscompat_43_sys_wait(struct lwp *l, void *v, register_t *retval) 761.1Schristos{ 771.18.4.1Smjf int error, status, was_zombie; 781.18.4.1Smjf int child_pid = WAIT_ANY; 791.18.4.1Smjf 801.18.4.1Smjf 811.18.4.1Smjf#ifdef PSL_ALLCC 821.18.4.1Smjf#else 831.18.4.1Smjf#endif 841.1Schristos 851.1Schristos#ifdef PSL_ALLCC 861.10Sthorpej if ((GETPS(l->l_md.md_regs) & PSL_ALLCC) != PSL_ALLCC) { 871.18.4.1Smjf error = do_sys_wait(l, &child_pid, &status, 0, NULL, &was_zombie); 881.1Schristos } else { 891.18.4.1Smjf error = do_sys_wait(l, &child_pid, &status, 901.18.4.1Smjf l->l_md.md_regs[R0], (struct rusage *)l->l_md.md_regs[R1], 911.18.4.1Smjf &was_zombie); 921.1Schristos } 931.1Schristos#else 941.18.4.1Smjf error = do_sys_wait(l, &child_pid, &status, 0, NULL, &was_zombie); 951.1Schristos#endif 961.18.4.1Smjf retval[0] = child_pid; 971.18.4.1Smjf retval[1] = status; 981.18.4.1Smjf return error; 991.1Schristos} 100