Date: Fri, 8 Aug 1997 00:40:01 -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: <199708080740.AAA29344@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: tetsuya@secom-sis.co.jp
Cc: peter@spinner.dialix.com.au, dg@root.com, FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/4243: file locking doesn't work for pipe
Date: Fri, 8 Aug 1997 16:38:32 +0900
I'm sorry I had forgot the BSD flock's mechanism,
so the following program I wrote is useless for BSD.
>----
>#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. :-(
Solaris's behavier is compatible with SYSV.
Linux's may be compatible with BSD.
--
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?199708080740.AAA29344>
