kern_exit.c (0d2afceedd4c08ee0e215f7d1d5399dda6fd210e) kern_exit.c (f3f0ca6051bef86fa8962f675d6eea17a29c2940)
1/*
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 *

--- 21 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 *

--- 21 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
39 * $Id: kern_exit.c,v 1.3 1994/08/02 07:41:59 davidg Exp $
39 * $Id: kern_exit.c,v 1.4 1994/08/06 07:15:03 davidg Exp $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/sysent.h>
44#include <sys/map.h>
45#include <sys/ioctl.h>
46#include <sys/proc.h>
47#include <sys/tty.h>
48#include <sys/time.h>
49#include <sys/resource.h>
50#include <sys/kernel.h>
51#include <sys/buf.h>

--- 225 unchanged lines hidden (view full) ---

277 cpu_exit(p);
278}
279
280struct wait_args {
281 int pid;
282 int *status;
283 int options;
284 struct rusage *rusage;
45#include <sys/map.h>
46#include <sys/ioctl.h>
47#include <sys/proc.h>
48#include <sys/tty.h>
49#include <sys/time.h>
50#include <sys/resource.h>
51#include <sys/kernel.h>
52#include <sys/buf.h>

--- 225 unchanged lines hidden (view full) ---

278 cpu_exit(p);
279}
280
281struct wait_args {
282 int pid;
283 int *status;
284 int options;
285 struct rusage *rusage;
285#ifdef COMPAT_43
286#if defined(COMPAT_43) || defined(IBCS2)
286 int compat; /* pseudo */
287#endif
288};
289
287 int compat; /* pseudo */
288#endif
289};
290
290#ifdef COMPAT_43
291#if defined(COMPAT_43) || defined(IBCS2)
291#if defined(hp300) || defined(luna68k)
292#include <machine/frame.h>
293#define GETPS(rp) ((struct frame *)(rp))->f_sr
294#else
295#define GETPS(rp) (rp)[PS]
296#endif
297
298int

--- 38 unchanged lines hidden (view full) ---

337int
338wait1(q, uap, retval)
339 register struct proc *q;
340 register struct wait_args *uap;
341 int retval[];
342{
343 register int nfound;
344 register struct proc *p, *t;
292#if defined(hp300) || defined(luna68k)
293#include <machine/frame.h>
294#define GETPS(rp) ((struct frame *)(rp))->f_sr
295#else
296#define GETPS(rp) (rp)[PS]
297#endif
298
299int

--- 38 unchanged lines hidden (view full) ---

338int
339wait1(q, uap, retval)
340 register struct proc *q;
341 register struct wait_args *uap;
342 int retval[];
343{
344 register int nfound;
345 register struct proc *p, *t;
345 int status, error;
346 int status, error, sig;
346
347 if (uap->pid == 0)
348 uap->pid = -q->p_pgid;
349#ifdef notyet
350 if (uap->options &~ (WUNTRACED|WNOHANG))
351 return (EINVAL);
352#endif
353loop:
354 nfound = 0;
355 for (p = q->p_cptr; p; p = p->p_osptr) {
356 if (uap->pid != WAIT_ANY &&
357 p->p_pid != uap->pid && p->p_pgid != -uap->pid)
358 continue;
359 nfound++;
347
348 if (uap->pid == 0)
349 uap->pid = -q->p_pgid;
350#ifdef notyet
351 if (uap->options &~ (WUNTRACED|WNOHANG))
352 return (EINVAL);
353#endif
354loop:
355 nfound = 0;
356 for (p = q->p_cptr; p; p = p->p_osptr) {
357 if (uap->pid != WAIT_ANY &&
358 p->p_pid != uap->pid && p->p_pgid != -uap->pid)
359 continue;
360 nfound++;
361#if defined(COMPAT_43) || defined(IBCS2)
362 if (q->p_sysent->sv_sigtbl) {
363 if (p->p_xstat > q->p_sysent->sv_sigsize)
364 sig = q->p_sysent->sv_sigsize + 1;
365 else
366 sig = q->p_sysent->sv_sigtbl[p->p_xstat];
367 } else
368 sig = p->p_xstat;
369#endif
360 if (p->p_stat == SZOMB) {
361 /* charge childs scheduling cpu usage to parent */
362 if( curproc->p_pid != 1)
363 curproc->p_estcpu += p->p_estcpu;
364
365 retval[0] = p->p_pid;
370 if (p->p_stat == SZOMB) {
371 /* charge childs scheduling cpu usage to parent */
372 if( curproc->p_pid != 1)
373 curproc->p_estcpu += p->p_estcpu;
374
375 retval[0] = p->p_pid;
366#ifdef COMPAT_43
376#if defined(COMPAT_43) || defined(IBCS2)
367 if (uap->compat)
377 if (uap->compat)
368 retval[1] = p->p_xstat;
378 retval[1] = sig;
369 else
370#endif
371 if (uap->status) {
372 status = p->p_xstat; /* convert to int */
373 if (error = copyout((caddr_t)&status,
374 (caddr_t)uap->status, sizeof(status)))
375 return (error);
376 }

--- 57 unchanged lines hidden (view full) ---

434 FREE(p, M_PROC);
435 nprocs--;
436 return (0);
437 }
438 if (p->p_stat == SSTOP && (p->p_flag & P_WAITED) == 0 &&
439 (p->p_flag & P_TRACED || uap->options & WUNTRACED)) {
440 p->p_flag |= P_WAITED;
441 retval[0] = p->p_pid;
379 else
380#endif
381 if (uap->status) {
382 status = p->p_xstat; /* convert to int */
383 if (error = copyout((caddr_t)&status,
384 (caddr_t)uap->status, sizeof(status)))
385 return (error);
386 }

--- 57 unchanged lines hidden (view full) ---

444 FREE(p, M_PROC);
445 nprocs--;
446 return (0);
447 }
448 if (p->p_stat == SSTOP && (p->p_flag & P_WAITED) == 0 &&
449 (p->p_flag & P_TRACED || uap->options & WUNTRACED)) {
450 p->p_flag |= P_WAITED;
451 retval[0] = p->p_pid;
442#ifdef COMPAT_43
452#if defined(COMPAT_43) || defined(IBCS2)
443 if (uap->compat) {
453 if (uap->compat) {
444 retval[1] = W_STOPCODE(p->p_xstat);
454 retval[1] = W_STOPCODE(sig);
445 error = 0;
446 } else
447#endif
448 if (uap->status) {
449 status = W_STOPCODE(p->p_xstat);
450 error = copyout((caddr_t)&status,
451 (caddr_t)uap->status, sizeof(status));
452 } else

--- 48 unchanged lines hidden ---
455 error = 0;
456 } else
457#endif
458 if (uap->status) {
459 status = W_STOPCODE(p->p_xstat);
460 error = copyout((caddr_t)&status,
461 (caddr_t)uap->status, sizeof(status));
462 } else

--- 48 unchanged lines hidden ---