Date: Sat, 6 Nov 1999 13:45:48 +0000 From: David Malone <dwmalone@maths.tcd.ie> To: Ollivier Robert <roberto@keltia.freenix.fr> Cc: FreeBSD Current Users' list <freebsd-current@FreeBSD.ORG> Subject: Re: Serious locking problem in CURRENT Message-ID: <19991106134548.A2921@walton.maths.tcd.ie> In-Reply-To: <19991106005016.A865@keltia.freenix.fr> References: <19991105225916.A14961@keltia.freenix.fr> <19991106005016.A865@keltia.freenix.fr>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Nov 06, 1999 at 12:50:16AM +0100, Ollivier Robert wrote: A child process seems to be able to let go of a parent's lock on 4.0 by closing a file discriptor, the same doesn't seem to be true on 3.3. For example, if you try to run two copies of the included program as on 3.3, you get a resource unavailable message. 12:57:walton 6% ./lockf_test /tmp/blah 5 & [1] 2453 13:01:walton 7% ./lockf_test /tmp/blah 5 Unable to open file: Resource temporarily unavailable 13:01:walton 8% [1] Done ./lockf_test /tmp/blah 5 On 4.0 two run concurrently quite happily: 12:54:gonzo 65% ./lockf_test /tmp/blah 5 & [1] 943 13:02:gonzo 66% ./lockf_test /tmp/blah 5 [1] Done ./lockf_test /tmp/blah 5 13:02:gonzo 67% If you remove the "if(fork==0){close(fd);}" it two copies will not run concurrently on 4.0. I'm not sure which behavior is correct, but I suspect the 3.0 behavior is, 'cos /usr/bin/lockf is broken by this on 4.0. David. #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc,char **argv) { int fd; if( argc != 3 ) { fprintf(stderr, "Usage: %s filename seconds\n", argv[0]); exit(1); } if( (fd = open(argv[1], O_RDONLY|O_CREAT|O_NONBLOCK|O_EXLOCK,0666)) == -1 ) { perror("Unable to open file"); exit(2); } if( fork() == 0 ) { close(fd); } sleep(atoi(argv[2])); exit(0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991106134548.A2921>