Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!sgi!shinobu!odin!sgihub!dragon!sam.wpd.sgi.com!pj From: pj@sam.wpd.sgi.com (Paul Jackson) Newsgroups: comp.sys.sgi Subject: Re: File locking problems Message-ID: <1991Jun13.233213.14609@dragon.wpd.sgi.com> Date: 13 Jun 91 23:32:13 GMT References: <9106131834.AA08574@sct60a.sunyct.edu> Sender: news@dragon.wpd.sgi.com (CNews Account) Reply-To: pj@sgi.com Organization: Silicon Graphics, Research & Development Lines: 16 In article <9106131834.AA08574@sct60a.sunyct.edu>, sweetmr@SCT60A.SUNYCT.EDU (michael sweet) writes: |> ... lockf(2) function doesn't seem to work properly |> if (fd = open("config_file", O_RDWR, 02644) < 0) |> .... |> if (lockf(fd, F_TLOCK, 0L) < 0) Change the open line to have parentheses around (fd = open(...)). Your current code sets fd to be the result of the boolean (open(...) < 0), which if the open succeeds is false. So fd is 0 (for false) and lockf(0,...) succeeds. -- I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj@wpd.sgi.com), x1373