Is there an equivalent of fseek for fd? I've been using int fds for a very long time, and want to use fseek... but I know there is no seek function.
Thanks in advance!
Normal returnIf successful, the fileno function returns the file descriptor number associated with an open stream (that is, one opened with the fopen , fdopen , or freopen functions).
fd is not a valid file descriptor or is not open for writing. fd refers to a datagram socket for which a peer address has not been set using connect(2). The user's quota of disk blocks on the file system containing the file referred to by fd has been exhausted. buf is outside your accessible address space.
So first unused file descriptor is 3 in file descriptor table. After that in close() system call is free it this 3 file descriptor and then after set 3 file descriptor as null. So when we called second open(), then first unused fd is also 3.
A file descriptor is an unsigned integer used by a process to identify an open file. The number of file descriptors available to a process is limited by the /OPEN_MAX control in the sys/limits. h file. The number of file descriptors is also controlled by the ulimit -n flag.
See the POSIX function lseek(2):
SYNOPSIS
#include <unistd.h> off_t lseek(int fildes, off_t offset, int whence);
DESCRIPTION
The
lseek()
function repositions the offset of the file descriptorfildes
to the argumentoffset
, according to the directivewhence
. The argumentfildes
must be an open file descriptor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With