1824363 Members
3127 Online
109669 Solutions
New Discussion

fcntl system call

 
manasa_1
Occasional Contributor

fcntl system call

Hello everyone,

could you please explain how to use fcntl system call with optins like F_SETFL and to set and reset the flags O_RDONLY.
1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: fcntl system call

Take a look at the man pages:
http://docs.hp.com/en/B2355-60130/fcntl.2.html
http://docs.hp.com/en/B2355-60130/fcntl.5.html

Unfortunately the documentation is pretty poor in that I have no idea of the difference between "file status" vs "file descriptor".
Searching this inter-web thingy shows it is a file status.
http://www.informit.com/articles/article.aspx?p=99706&seqNum=13

int status, status1;
// get initial file status bits
status = fcntl(fd, F_GETFL, 0);
// set read only
status1 = fcntl(fd, F_SETFL, status & ~O_ACCMODE | O_RDONLY);
// set read write
status1 = fcntl(fd, F_SETFL, status & ~O_ACCMODE | O_RDWR);