Return to BSD News archive
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!spool.mu.edu!sol.ctr.columbia.edu!news.kei.com!ub!dsinc!netnews.upenn.edu!cronkite.ocis.temple.edu!astro.ocis.temple.edu!clj From: clj@astro.ocis.temple.edu (Cheng Li Jian) Newsgroups: comp.unix.bsd Subject: Trouble with flock Message-ID: <1993Sep23.054830.29818@cronkite.ocis.temple.edu> Date: 23 Sep 93 05:48:30 GMT Sender: news@cronkite.ocis.temple.edu (NetWork News (readnews)) Organization: Temple University Lines: 17 Nntp-Posting-Host: astro.ocis.temple.edu X-Newsreader: TIN [version 1.2 PL0] Hi, I have a trouble with flock. I am doing some interprocessing work. After tracing the problem, I find out problem it is following: flock always return -1(fail lock) instead of 0, I think j should equal to 0,(even I run this process along, j always equal to -1, why?) main() { FILE *fp; int j; if ((fp=fopen("buffer","w+"))==NULL) { printf('Can not open buffer file, exit!'); exit(0); } j=flock(fp,LOCK_EX|LOCK_NB); }