Date: Thu, 7 Aug 1997 17:25:16 +0900 From: tetsuya@secom-sis.co.jp To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: kern/4243: file locking doesn't work for pipe Message-ID: <199708070825.RAA10674@juria.secom-sis.co.jp> Resent-Message-ID: <199708070830.BAA27289@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 4243 >Category: kern >Synopsis: file locking doesn't work for pipe >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Aug 7 01:30:01 PDT 1997 >Last-Modified: >Originator: Tetsuya Furukawa >Organization: Secom Information System Co.,Ltd. >Release: FreeBSD 2.2-STABLE i386 >Environment: FreeBSD 2.2-STABLE i386 on July 11, 1997 >Description: In flock() in /sys/kern/kern_descrip.c, the following statement: f (fp->f_type != DTYPE_VNODE) return (EOPNOTSUPP); rejects the file descriptor if fp->f_type == DTYPE_PIPE. F_SETLK and F_GETLK of fcntl() have also the similar statements. "Program rewriting map" (RewriteMap mapname prg:filename) of the URL rewriting module (mod_rewrite) of the Apache HTTP server uses file locking for pipe, so FreeBSD users cannot use the fine feature of "program rewriting map". >How-To-Repeat: The following program prints "flock: Operation not supported". -------- #include <sys/file.h> #include <stdio.h> #include <unistd.h> int main() { int fds[2]; char c; pipe(fds); if (flock(fds[1], LOCK_EX) == -1) perror("flock"); write(fds[1], "a", 1); read(fds[0], &c, 1); return 0; } -------- >Fix: Maybe, modify the three lines like if (fp->f_type != DTYPE_VNODE) into if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_PIPE) I have not tried it, and I'm not convinced that it is safe and right for I don't know detail of the kernel. >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199708070825.RAA10674>