Illegal seek异常是哪儿冒出来的
Illegal seek错误是哪儿冒出来的#include stdio.h#include unistd.h#include errno.hint main(){uid
Illegal seek错误是哪儿冒出来的
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
int main(){
uid_t ruid = 0;
uid_t euid = 0;
ruid = getuid();
perror("tips");
euid = geteuid();
perror("tips");
return 0;
}
上面这段代码执行后
$ gcc seek_error.c -o seek_error
$ ./seek_error
tips: Success
tips: Illegal seek
结果是这样的,请问这里的Illegal seek错误是哪儿冒出来的
执行环境:
Linux localhost.localdomain 2.6.18-194.el5xen #1 SMP Fri Apr 2 16:16:54 EDT 2010 i686 i686 i386 GNU/Linux
[解决办法]SYNOPSIS
#include <unistd.h>
#include <sys/types.h>
uid_t getuid(void);
uid_t geteuid(void);
DESCRIPTION
getuid() returns the real user ID of the calling process.
geteuid() returns the effective user ID of the calling process.
ERRORS
These functions are always successful.
这个函数总是返回成功, 你用perror输出 错误信息没有任何意义,
一般的用法是 判断函数返回值, 只有返回值 < 0 , 然后再执行 perror 输出错误信息才有意义。
所以你也不用管这个 Illegal seek 哪里来的了。 可能 Illegal seek 也并不代表是错误。
[解决办法]楼上说的在理, 先检查返回值。
[解决办法]检查返回值,然后根据返回值确定错误类型.