【问题标题】:Why does open() fails every time with EAGAIN?为什么每次使用 EAGAIN 时 open() 都会失败?
【发布时间】:2015-06-09 20:09:40
【问题描述】:

为什么像 Apache 这样的程序无法打开纯文件?在strace 下运行显示:

open("access.log", O_WRONLY|O_CREAT|O_APPEND|O_CLOEXEC, 0666) = 11

11 代表EAGAINEWOULDBLOCK

地点:

$ ls -l access.log
-rw-rw-rw- 1 root root 2 Jun  9 17:52 access.log

如果我将su 设为www-data,我可以安全地写入文件。

【问题讨论】:

    标签: linux apache2 strace


    【解决方案1】:

    11 是文件描述符而不是错误代码。这意味着您看到的 open 呼叫成功并没有失败。如果 open 失败,它将返回 -1 并且 strace 会显示如下内容:

    open("access.log", O_RDONLY)            = -1 ENOENT (No such file or directory)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-16
      • 1970-01-01
      • 2013-11-21
      • 1970-01-01
      • 2015-05-30
      • 1970-01-01
      相关资源
      最近更新 更多