lseek giving ESPIPE error

2.5k views Asked by At

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.

1

There are 1 answers

4
Klas Lindbäck On BEST ANSWER

There is no guarantee that errnowill be reset on a successful call.

You should only check the value of errno if the return value indicates an error.