Date: Fri, 8 Aug 1997 00:00:02 -0700 (PDT) From: tetsuya@secom-sis.co.jp (Tetsuya Furukawa) To: freebsd-bugs Subject: Re: kern/4243: file locking doesn't work for pipe Message-ID: <199708080700.AAA27925@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/4243; it has been noted by GNATS. From: tetsuya@secom-sis.co.jp (Tetsuya Furukawa) To: peter@spinner.dialix.com.au Cc: dg@root.com, FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: kern/4243: file locking doesn't work for pipe Date: Fri, 8 Aug 1997 15:58:26 +0900 Peter Wemm wrote: >Yeah, it's kinda nonsensical, but useful in certain situations where the >same fd is shared between processes. The purpose that Apache's URL rewriting module locks a pipe is exactly that. The latest version of the module says: ---- /* The locking support for the RewriteMap programs: Locking a pipe to the child works fine under most Unix derivates, but braindead SunOS 4.1.x has problems with this approach... */ #define USE_PIPE_LOCKING 1 #ifdef SUNOS4 #undef USE_PIPE_LOCKING #endif ---- <URL:http://www.engelschall.com/sw/mod_rewrite/distrib/mod_rewrite-SNAP/src/mod_rewrite.h> I made a simple program to check whether flock() works for a pipe. ---- #include <sys/file.h> #include <sys/errno.h> #include <errno.h> #include <stdio.h> #include <unistd.h> int main() { int fds[2]; char c; pipe(fds); if (fork() == 0) { /* child */ flock(fds[1], LOCK_EX); sleep(2); exit(0); } /* parent */ sleep(1); if (flock(fds[1], LOCK_EX | LOCK_NB) == -1) { if (errno == EWOULDBLOCK) printf("flock works fine.\n"); else printf("flock fails: %s\n", strerror(errno)); } else printf("flock is discarded.\n"); return 0; } ---- Results: FreeBSD 2.2-STABLE i386 flock fails: Operation not supported FreeBSD 2.1.7.1-RELEASE i386 flock fails: Operation not supported Linux 2.0.29 i686 flock is discarded. Solaris 2.5.1 sparc flock works fine. Linux is really braindead. :-( I will send the results to the developer of the Apache's module and request to use the other locking method. -- Tetsuya FURUKAWA in Tokyo, Japan PGP Key fingerprint = C2 86 A6 7C 72 A0 A1 94 F4 4C 83 9D D1 E3 47 BD
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199708080700.AAA27925>