1 ?RCS: $Id: d_fcntl_can_lock.U,v$
3 ?RCS: Copyright (c) 2000, Andrew Dougherty
5 ?RCS: You may distribute under the terms of either the GNU General Public
6 ?RCS: License or the Artistic License, as specified in the README file.
8 ?RCS: $Log: d_fcntl_can_lock.U,v $
10 ?MAKE:d_fcntl_can_lock: d_fcntl Compile Setvar cat rm_try run signal_t i_stdlib
11 ?MAKE: -pick add $@ %<
13 ?S: This variable conditionally defines the FCNTL_CAN_LOCK symbol
14 ?S: and indicates whether file locking with fcntl() works.
17 ?C: This symbol, if defined, indicates that fcntl() can be used
18 ?C: for file locking. Normally on Unix systems this is defined.
19 ?C: It may be undefined on VMS.
21 ?H:#$d_fcntl_can_lock FCNTL_CAN_LOCK /**/
24 ?LINT: set d_fcntl_can_lock
25 ?X: fcntl may not be fully functional. As of November 2000, on VMS and
26 ?X: DOS/DJGPP, fctnl-based locking doesn't work.
27 ?X: Thanks to Craig A. Berry <craig.berry@psinetcs.com> for this test.
28 : See if fcntl-based locking works.
38 $signal_t blech(int x) { exit(3); }
40 #if defined(F_SETLK) && defined(F_SETLKW)
43 fd = open("try.c", O_RDONLY);
44 flock.l_type = F_RDLCK;
45 flock.l_whence = SEEK_SET;
46 flock.l_start = flock.l_len = 0;
47 signal(SIGALRM, blech);
49 retval = fcntl(fd, F_SETLK, &flock);
51 (retval < 0 ? exit(2) : exit(0));
57 echo "Checking if fcntl-based file locking works... "
61 if eval $compile_ok; then
63 echo "Yes, it seems to work."
66 echo "Nope, it didn't work."
71 *** I had to forcibly timeout from fcntl(..., F_SETLK, ...).
72 *** This is (almost) impossible.
73 *** If your NFS lock daemons are not feeling well, something like
74 *** this may happen, please investigate. Cannot continue, aborting.
82 echo "I'm unable to compile the test program, so I'll assume not."
87 echo "Nope, since you don't even have fcntl()."