make setpgid(pid, pgrp) return EINVAL if pgrp < 0 as required by POSIX.1;

from Klaus Klein in PR standards/3395.
This commit is contained in:
mikel 1997-03-27 06:14:03 +00:00
parent bf22891897
commit 19fd4b60de
2 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: setpgid.2,v 1.8 1995/02/27 12:36:55 cgd Exp $
.\" $NetBSD: setpgid.2,v 1.9 1997/03/27 06:14:04 mikel Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -74,6 +74,10 @@ The value of the
.Fa pid
argument matches the process ID of a child process of the calling process,
and the child process has successfully executed one of the exec functions.
.It Bq Er EINVAL
The value of the
.Fa pgrp
argument is less than zero.
.It Bq Er EPERM
The effective user ID of the requested process is different
from that of the caller and the process is not a descendant

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_prot.c,v 1.38 1996/12/22 10:21:08 cgd Exp $ */
/* $NetBSD: kern_prot.c,v 1.39 1997/03/27 06:14:03 mikel Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
@ -226,6 +226,7 @@ sys_setsid(p, v, retval)
*
* caller does setpgid(targpid, targpgid)
*
* pgid must be in valid range (EINVAL)
* pid must be caller or child of caller (ESRCH)
* if a child
* pid must be in same session (EPERM)
@ -253,6 +254,9 @@ sys_setpgid(curp, v, retval)
SCARG(uap, pgid) = (short) SCARG(uap, pgid); /* XXX */
#endif
if (SCARG(uap, pgid) < 0)
return (EINVAL);
if (SCARG(uap, pid) != 0 && SCARG(uap, pid) != curp->p_pid) {
if ((targp = pfind(SCARG(uap, pid))) == 0 || !inferior(targp))
return (ESRCH);