I have a FILE *, returned by a call to fopen(). I need to get a file descriptor from it, to make calls like fsync(fd) on it. What’s the function to get a file descriptor from a file pointer? Answer The proper function is int fileno(FILE *stream). It can be found in <stdio.h>, and is a POSIX standard but not
Tag: file
fcntl, lockf, which is better to use for file locking?
Looking for information regarding the advantages and disadvantages of both fcntl and lockf for file locking. For example which is better to use for portability? I am currently coding a linux daemon and wondering which is better suited to use for enforcing mutual exclusion. Answer What is the difference between lockf and fcntl: On many systems, the lockf() library routine