How to implement File locking for fstream class object

Ajay Bansal Ajay_Bansal@infosys.com
Mon Feb 3 15:04:00 GMT 2003


Hi,

I am using fstream in my application. I need to implement locking on my
file. Earlier fd method of filebuf class was available which gave me
filedescriptor. That file descriptor can be used by lockf or fcntl
system calls to implement file locking. How do I achive file locking
using me fstream object now?????

Following is the code snipet used for locking the file:

fcntl(m_file.rdbuf()->fd(), F_SETFD, FD_CLOEXEC);

How can achive the above functionality(file locking) on gcc 3.2.1????


Kindly advise,
Ajay



More information about the Libstdc++ mailing list