From: bluhm Date: Wed, 21 Oct 2015 16:09:13 +0000 (+0000) Subject: Setting fcntl(F_SETOWN) for a pipe failed with inappropriate ioctl X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e4bed001e3846d1f10dd3dbda8ec679984dc7046;p=openbsd Setting fcntl(F_SETOWN) for a pipe failed with inappropriate ioctl for device. In sys_fcntl() the ioctl(TIOCSPGRP) is called, but the pipe expects SIOCSPGRP. Sockets have a specal case for the same reason, so adapt the special code for pipes. OK millert@ --- diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 6de08b92085..2c1fe0b0a35 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.121 2015/10/16 13:37:43 millert Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.122 2015/10/21 16:09:13 bluhm Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -429,6 +429,10 @@ restart: *retval = ((struct socket *)fp->f_data)->so_pgid; break; } + if (fp->f_type == DTYPE_PIPE) { + *retval = ((struct pipe *)fp->f_data)->pipe_pgid; + break; + } error = (*fp->f_ops->fo_ioctl) (fp, TIOCGPGRP, (caddr_t)&tmp, p); *retval = -tmp; @@ -443,6 +447,12 @@ restart: so->so_sigeuid = p->p_ucred->cr_uid; break; } + if (fp->f_type == DTYPE_PIPE) { + struct pipe *mpipe = (struct pipe *)fp->f_data; + + mpipe->pipe_pgid = (long)SCARG(uap, arg); + break; + } if ((long)SCARG(uap, arg) <= 0) { SCARG(uap, arg) = (void *)(-(long)SCARG(uap, arg)); } else {