0aslam0
0aslam0

Reputation: 1963

lseek giving ESPIPE error

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.

Upvotes: 0

Views: 2710

Answers (1)

Klas Lindbäck
Klas Lindbäck

Reputation: 33273

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.

Upvotes: 1

Related Questions