why lockf is failing
Ajay Bansal
Ajay_Bansal@infosys.com
Sun Feb 2 17:47:00 GMT 2003
I know that i missing something very stupid in the following program...
but what is it??
"open.cpp" 23 lines, 428 characters
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <iostream.h>
using namespace std;
int main()
{
int fd;
fd = open("/home/hpux/ajay/project/Testing/sti-test/ajay", 0);
cout<<"File descriptor we got is "<<fd<<endl;
lockf(fd, F_LOCK, 0);
cout<<"Error no is "<<errno<<" & dscription is
"<<strerror(errno)<<endl;
return 1;
}
$g++ open.cpp
$ ./a.out
File descriptor we got is 3
Error no is Bad file descriptor & dscription is 9
Does this mean that we can not have lock on a file which has been opeed
only for reading?????
TIA (Thanks in Advance)
Ajay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20030202/38da4384/attachment.htm>
More information about the Gcc-help
mailing list