Reputation: 177
A small question about lseek
(C system call). I know that upon failure the return value of the function will be negative. Can we know for sure that if the return value is not negative the function actually moved to the desired location?
Upvotes: 2
Views: 512
Reputation: 386676
If the value is (off_t)-1
, there was an error.
If the value isn't (off_t)-1
, the call was successful.
From my system's man page,
Upon successful completion,
lseek()
returns the resulting offset location as measured in bytes from the beginning of the file. On error, the value(off_t)-1
is returned anderrno
is set to indicate the error.
There are mentions that off_t
must be a signed type, so it appear safe to check if the result is negative or non-negative.
Upvotes: 2