Path: utzoo!utgpu!watserv1!ria!uwovax!reggers From: reggers@uwovax.uwo.ca (Reg Quinton) Newsgroups: comp.sys.mips Subject: flock(2) is snafu Summary: flock doesn't work Message-ID: <6888.26e7cfc0@uwovax.uwo.ca> Date: 7 Sep 90 20:50:08 GMT Lines: 46 I've been trying to get mh running on a Mips/120 here at Western. I'm building things in a BSD environment, my search path is such that I hit the bsd43/cc rather than the SYSV version. Anyways, I've got stuck on the flock call used for file locking. Here's a very simple program that demonstrates the problem. ----- cut here for test.c ----- #include #include #define FILNAM ".cshrc" #define MODE O_RDONLY #define NOTOK (-1) main(argc,argv) int argc; char *argv[]; { int fd; if ((fd=open(FILNAM,MODE,0777)) == NOTOK) { perror(FILNAM); exit(1); } if (flock(fd,LOCK_EX | LOCK_NB) == NOTOK) { perror("lock"); exit(2); } printf("She works!\n"); } ----- cut here for test.c ----- If I "make test" and then "./test" in my home directory (where I have a .cshrc file) I always get a perror message of this sort: lock: Bad file number Any ideas what I'm doing wrong? Or how I can get this to work? P.S. the above code works fine on our Suns and Next machines.. -- Telephone: (519) 661 2151 x6026 (a real person and not a machine) Canada: reggers@uwo.ca (used to be UWO.CDN) BITNET: reggers@uwovax.BITNET (for the ethnocentric) UUCP: reggers@ria.UUCP (...uunet!utai!ria!reggers)