Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!panix!panix.com!mrbrklyn From: Ruben Safir Newsgroups: comp.os.linux.development.apps Subject: Re: C++ file locking Date: Mon, 27 Jun 2011 12:29:47 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 26 Message-ID: References: <16265495-eb93-4e2e-a46c-f16bb6b19d9e@b1g2000yql.googlegroups.com> <87y61akryv.fsf@araminta.anjou.terraraq.org.uk> NNTP-Posting-Host: panix2.panix.com X-Trace: reader1.panix.com 1309177787 1389 166.84.1.2 (27 Jun 2011 12:29:47 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Mon, 27 Jun 2011 12:29:47 +0000 (UTC) User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (NetBSD/5.1 (i386)) Xref: x330-a1.tempe.blueboxinc.net comp.os.linux.development.apps:166 Richard Kettlewell wrote: > Ruben Safir writes: >> Lukas 'Erdk' Redynk wrote: > >>> You could try this: >>> http://linux.die.net/man/3/lockf >>> or >>> http://www.manpagez.com/man/2/fcntl/ - especially F_GETLK and F_SETLK >> >> Yes but these both require you to get a file descriptor from the open >> call, effectively doing an end run around ios_base. > > Yes. > >> Is there no purely C++ mechanism of do this, or aquiring the file >> descriptor from iosteams? > > http://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_io.html > I finally got this to work today, which wasn't easy with the documentation that was provided. One of the things that puzzled me was what to use for the template argument. I used char. Ruben