Linux 为什么每次使用EAGAIN时open()都会失败?
为什么像Apache这样的程序无法打开普通文件?在Linux 为什么每次使用EAGAIN时open()都会失败?,linux,apache2,strace,Linux,Apache2,Strace,为什么像Apache这样的程序无法打开普通文件?在strace下运行它会显示: open("access.log", O_WRONLY|O_CREAT|O_APPEND|O_CLOEXEC, 0666) = 11 11代表EAGAIN或eWoldBlock 其中: $ ls -l access.log -rw-rw-rw- 1 root root 2 Jun 9 17:52 access.log 如果我su作为www-data我可以安全地写入文件。11是文件描述符而不是错误代码。这意味着您
strace
下运行它会显示:
open("access.log", O_WRONLY|O_CREAT|O_APPEND|O_CLOEXEC, 0666) = 11
11
代表EAGAIN
或eWoldBlock
其中:
$ ls -l access.log
-rw-rw-rw- 1 root root 2 Jun 9 17:52 access.log
如果我
su
作为www-data
我可以安全地写入文件。11
是文件描述符而不是错误代码。这意味着您看到的open
调用已成功,但未失败。如果open
失败,它将返回-1
,strace将显示如下内容:
open("access.log", O_RDONLY) = -1 ENOENT (No such file or directory)