I have a normal file opened, it acts as a database of records. I opened it as:
fd = open ("file", O_CREAT | O_APPEND | O_RDWR, 0644);
Then in my find_record
function, I move the offset to the beginning.
ret_val = lseek(fd, 0, SEEK_SET);
Its throwing an ESPIPE
error. Right now I don't know what's happening.
Is my file descriptor treated as a pipe? if yes, Why?
Is lseek
actually working ? Its should be beacuse the ret_val
is not -1.
There is no guarantee that
errno
will be reset on a successful call.You should only check the value of
errno
if the return value indicates an error.