OPEN_MAX
단일 프로그램에 허용되는 최대 열린 파일 수를 정의하는 상수입니다.
Beginning Linux Programming 4th Edition, Page 101 에 따르면 :
limits.h의 상수 OPEN_MAX에 의해 정의 된 한계는 시스템마다 다릅니다.
내 시스템 limits.h
에서 디렉토리 의 파일 /usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed
에는이 상수가 없습니다. 내가 잘못보고 limits.h
있거나 OPEN_MAX
2008 년 이후 위치가 변경 되었습니까?
그만한 가치가 있기 위해 Beginning Linux Programming 의 제 4 판은 2007 년에 출판되었습니다. 그것의 일부는 약간 오래된 것일 수 있습니다. (내가 읽지 않은 책에 대한 비판은 아닙니다.)
OPEN_MAX
적어도 Linux 시스템에서는 더 이상 사용되지 않는 것으로 보입니다 . 그 이유는 동시에 열 수있는 최대 파일 수가 고정되어 있지 않기 때문에 정수 리터럴로 확장되는 매크로는 해당 정보를 얻는 좋은 방법이 아닙니다.
FOPEN_MAX
비슷한 또 다른 매크로 가 있습니다. 이유 OPEN_MAX
와를 FOPEN_MAX
정의한 경우 서로 다른 값을 가져야 하는 이유는 생각할 수 없습니다 . 그러나 FOPEN_MAX
C 언어 표준에 의해 요구되므로 시스템은 그것을 정의하지 않을 수 없습니다. C 표준은FOPEN_MAX
구현에서 동시에 열 수있는 최소 파일 수인 정수 상수 표현식으로 확장
( "최소"라는 단어가 혼동되는 경우 프로그램이 최소한 한 번에 많은 파일을 열 수 있음을 보증합니다 .)
열 수있는 현재 최대 파일 수 를 원하면 sysconf()
함수를 살펴보십시오 . 내 시스템에서 sysconf(_SC_OPEN_MAX)
1024를 반환합니다. ( sysconf()
man 페이지는 기호를 나타냅니다 OPEN_MAX
. 이것은 카운트가 아니라에 의해 인식되는 값이며 sysconf()
내 시스템에 정의되어 있지 않습니다.)
우분투 시스템에서 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.
*/
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다