c中lseek系统调用成功
success of lseek system call in c
一个关于lseek
(C系统调用)的小问题。我知道失败时函数的 return 值将为负数。我们能否确定如果 return 值不是负数,函数实际上移动到了所需位置?
如果值为 (off_t)-1
,则出现错误。
如果值不是(off_t)-1
,调用成功。
来自我系统的手册页,
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 and errno
is set to indicate the error.
有 mentions off_t
必须是有符号类型,因此检查结果是负数还是非负数似乎是安全的。
一个关于lseek
(C系统调用)的小问题。我知道失败时函数的 return 值将为负数。我们能否确定如果 return 值不是负数,函数实际上移动到了所需位置?
如果值为 (off_t)-1
,则出现错误。
如果值不是(off_t)-1
,调用成功。
来自我系统的手册页,
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.
有 mentions off_t
必须是有符号类型,因此检查结果是负数还是非负数似乎是安全的。