Setting fcntl(F_SETOWN) for a pipe failed with inappropriate ioctl
authorbluhm <bluhm@openbsd.org>
Wed, 21 Oct 2015 16:09:13 +0000 (16:09 +0000)
committerbluhm <bluhm@openbsd.org>
Wed, 21 Oct 2015 16:09:13 +0000 (16:09 +0000)
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@

sys/kern/kern_descrip.c

index 6de08b9..2c1fe0b 100644 (file)
@@ -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 {