作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
因为似乎没有办法在exec
之后使用已经打开的fd,
为什么这个标志不是默认的?
最佳答案
文件描述符可以在 exec
调用之后使用;例如,这就是 Unix 实用程序从 shell 获取标准输入/输出/错误 fds 的方式。
Close-on-exec 不是默认设置,因为 POSIX standard (和 Unix 传统)要求相反的行为:
File descriptors open in the calling process image shall remain open in the new process image, except for those whose close-on- exec flag
FD_CLOEXEC
is set.
关于linux - 为什么 close_on_exec 不是默认配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9583845/
因为似乎没有办法在exec之后使用已经打开的fd, 为什么这个标志不是默认的? 最佳答案 文件描述符可以在 exec 调用之后使用;例如,这就是 Unix 实用程序从 shell 获取标准输入/输出/
我是一名优秀的程序员,十分优秀!