linux open 源码 在哪,OPEN_MAX在哪里为Linux系统定义?

值得一提的是,Beginning Linux Programming的第4版于2007年出版;它的一部分可能有点过时了. (这不是对这本书的批评,我还没读过.)

看来OPEN_MAX已被弃用,至少在Linux系统上是这样.原因似乎是可以同时打开的最大文件数不固定,因此扩展为整数字的宏不是获取该信息的好方法.

另一个宏FOPEN_MAX应该是相似的;我想不出OPEN_MAX和FOPEN_MAX如果定义的话应该有不同的值的原因.但是FOPEN_MAX是C语言标准的强制要求,因此系统没有选择不定义它. C标准说FOPEN_MAX

expands to an integer constant expression that is the minimum number of files that

the implementation guarantees can be open simultaneously

(如果“最小”这个词令人困惑,则可以保证程序可以同时打开至少那么多文件.)

如果您想要当前可以打开的最大文件数,请查看sysconf()功能;在我的系统上,sysconf(_SC_OPEN_MAX)返回1024.(sysconf()手册页引用符号OPEN_MAX.这不是计数,而是sysconf()识别的值.并且它没有在我的系统上定义.)

我在我的Ubuntu系统上搜索了OPEN_MAX(字匹配,因此不包括FOPEN_MAX),并发现以下内容(这些显然只是简短的摘录):

/usr/include/X11/Xos.h:

# ifdef __GNU__

# define PATH_MAX 4096

# define MAXPATHLEN 4096

# define OPEN_MAX 256 /* We define a reasonable limit. */

# endif

/usr/include/i386-linux-gnu/bits/local_lim.h:

/* The kernel header pollutes the namespace with the NR_OPEN symbol

and defines LINK_MAX although filesystems have different maxima. A

similar thing is true for OPEN_MAX: the limit can be changed at

runtime and therefore the macro must not be defined. Remove this

after including the header if necessary. */

#ifndef NR_OPEN

# define __undef_NR_OPEN

#endif

#ifndef LINK_MAX

# define __undef_LINK_MAX

#endif

#ifndef OPEN_MAX

# define __undef_OPEN_MAX

#endif

#ifndef ARG_MAX

# define __undef_ARG_MAX

#endif

/usr/include/i386-linux-gnu/bits/xopen_lim.h:

/* We do not provide fixed values for

ARG_MAX Maximum length of argument to the `exec' function

including environment data.

ATEXIT_MAX Maximum number of functions that may be registered

with `atexit'.

CHILD_MAX Maximum number of simultaneous processes per real

user ID.

OPEN_MAX Maximum number of files that one process can have open

at anyone time.

PAGESIZE

PAGE_SIZE Size of bytes of a page.

PASS_MAX Maximum number of significant bytes in a password.

We only provide a fixed limit for

IOV_MAX Maximum number of `iovec' structures that one process has

available for use with `readv' or writev'.

if this is indeed fixed by the underlying system.

*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值