Sponsored Content
Top Forums Programming Huge difference between _POSIX_OPEN_MAX and sysconf(_SC_OPEN_MAX). Post 302400131 by gencon on Tuesday 2nd of March 2010 09:30:31 AM
Old 03-02-2010
Huge difference between _POSIX_OPEN_MAX and sysconf(_SC_OPEN_MAX).

On my Linux system there seems to be a massive difference between the value of _POSIX_OPEN_MAX and what sysconf(_SC_OPEN_MAX) returns and also what I'd expect from the table of examples of configuration limits from Advanced Programming In The UNIX Environment, 2nd Ed.

_POSIX_OPEN_MAX: 16
sysconf(_SC_OPEN_MAX): 65535

Advanced Programming In The UNIX Environment, 2nd Ed, 2005
Figure 2.14. Examples of configuration limits

OPEN_MAX:
FreeBSD 5.2.1: 1735
Linux 2.4.22: 1024
Mac OS X 10.3: 256
Solaris 9: 256

Doesn't the value of 65,535 returned by sysconf(_SC_OPEN_MAX) seem way too high?

Code:
#ifdef _POSIX_OPEN_MAX
        printf("_POSIX_OPEN_MAX: %d\n", _POSIX_OPEN_MAX);
#endif
#ifdef OPEN_MAX
    printf("OPEN_MAX: %d\n", OPEN_MAX);
#endif
#ifdef FOPEN_MAX
    printf("FOPEN_MAX: %d\n", FOPEN_MAX);
#endif

errno = 0;

long om = sysconf(_SC_OPEN_MAX);
printf("errno: %d\n", errno);
printf("_SC_OPEN_MAX: %ld\n", om);

long pcnm = pathconf("/home/gencon/up.zip", _PC_NAME_MAX);
printf("errno: %d\n", errno);
printf("_PC_NAME_MAX: %ld\n", pcnm);

long pcpm = pathconf("/home/gencon/", _PC_PATH_MAX);
printf("errno: %d\n", errno);
printf("_PC_PATH_MAX: %ld\n", pcpm);

Outputs:
_POSIX_OPEN_MAX: 16
FOPEN_MAX: 16
errno: 0
_SC_OPEN_MAX: 65535
errno: 0
_PC_NAME_MAX: 255
errno: 0
_PC_PATH_MAX: 4096

 

9 More Discussions You Might Find Interesting

1. Solaris

Huge PI in vmstat

This is something nowbody around me can explain: vmstat (-S 5) shows a huge number of PI but when I try to monitor it in parallel with iostat - there is no IO activity to be seen that would correspond to this. I have 16G RAM and 32G swap file. I'll really appreciate if somebody can explain it.... (9 Replies)
Discussion started by: dkvent
9 Replies

2. UNIX for Dummies Questions & Answers

Difference between two huge files

Hi, As per my requirement, I need to take difference between two big files(around 6.5 GB) and get the difference to a output file without any line numbers or '<' or '>' in front of each new line. As DIFF command wont work for big files, i tried to use BDIFF instead. I am getting incorrect... (13 Replies)
Discussion started by: pyaranoid
13 Replies

3. Ubuntu

kernel-huge

Hi All, I have a uname -a Linux caws101arop 2.6.9-67.0.20.ELsmp #1 SMP Wed Jun 18 12:35:02 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux And I'm having lots of problem especially when the web server got new two additional website. Before the memory was just 12G but we upgraded it to 65G. Do... (1 Reply)
Discussion started by: itik
1 Replies

4. AIX

Huge difference in reported Disk usage between ls,df and du

IBM RS6000 F50 AIX 4.3.2 i am having trouble in calculating the actual size of a set of directories and reconciling the results with the actual Hard Disk space used I have 33GB disk which is showing 7.8GB used, a byte count of the files in the directory/sub-dirs i`m interested in is 48GB,... (4 Replies)
Discussion started by: cooperuf
4 Replies

5. Shell Programming and Scripting

Three Difference File Huge Data Comparison Problem.

I got three different file: Part of File 1 ARTPHDFGAA . . Part of File 2 ARTGHHYESA . . Part of File 3 ARTPOLYWEA . . (4 Replies)
Discussion started by: patrick87
4 Replies

6. Programming

what is the main difference between difference between using nonatomic lseek and O_APPEND

I think both write at the end of the file ...... but is there a sharp difference between those 2 instruction ..... thank you this is my 3rd question today forgive me :D (1 Reply)
Discussion started by: fwrlfo
1 Replies

7. Shell Programming and Scripting

Difference between two huge .csv files

Hi all, I need help on getting difference between 2 .csv files. I have 2 large . csv files which has equal number of columns. I nned to compare them and get output in new file which will have difference olny. E.g. File1.csv Name, Date, age,number Sakshi, 16-12-2011, 22, 56 Akash,... (10 Replies)
Discussion started by: Dimple
10 Replies

8. UNIX for Dummies Questions & Answers

Shc script size limitation and "_SC_ARG_MAX (see sysconf(2))" parameter

I wish to change the parameter (which I do not understand exactly what it is and I wish to) and be able to use shc with very long bash scripts (2 Replies)
Discussion started by: frad
2 Replies

9. Shell Programming and Scripting

awk to calculate difference of split and sum the difference

In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13. I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Discussion started by: cmccabe
2 Replies
SYSCONF(3)						     Linux Programmer's Manual							SYSCONF(3)

NAME
sysconf - Get configuration information at runtime SYNOPSIS
#include <unistd.h> long sysconf(int name); DESCRIPTION
sysconf() provides a way for the application to determine values for system limits or options at runtime. The equivalent macros defined in <unistd.h> can only give conservative values; if an application wants to take advantage of values which may change, a call to sysconf() can be made, which may yield more liberal results. For getting information about a particular file, see fpathconf() or pathconf(). The following values are supported for name. First, the POSIX.1 compatible values: _SC_ARG_MAX The maximum length of the arguments to the exec() family of functions; the corresponding macro is ARG_MAX. _SC_CHILD_MAX The number of simultaneous processes per user id, the corresponding macro is CHILD_MAX. _SC_CLK_TCK The number of clock ticks per second; the corresponding macro was CLK_TCK. This macro is obsolete now. (Note that the macro CLOCKS_PER_SEC does not give information: it must equal 1000000.) _SC_STREAM_MAX The maximum number of streams that a process can have open at any time. The corresponding POSIX macro is STREAM_MAX, the corre- sponding standard C macro is FOPEN_MAX. _SC_TZNAME_MAX The maximum number of bytes in a timezone name, the corresponding macro is TZNAME_MAX. _SC_OPEN_MAX The maximum number of files that a process can have open at any time, the corresponding macro is OPEN_MAX. _SC_JOB_CONTROL This indicates whether POSIX - style job control is supported, the corresponding macro is _POSIX_JOB_CONTROL. _SC_SAVED_IDS This indicates whether a process has a saved set-user-ID and a saved set-group-ID; the corresponding macro is _POSIX_SAVED_IDS. _SC_VERSION indicates the year and month the POSIX.1 standard was approved in the format YYYYMML;the value 199009L indicates the Sept. 1990 revision. The corresponding macro is _POSIX_VERSION. Next, the POSIX.2 values: _SC_BC_BASE_MAX indicates the maximum obase value accepted by the bc(1) utility; the corresponding macro is BC_BASE_MAX. _SC_BC_DIM_MAX indicates the maximum value of elements permitted in an array by bc(1); the corresponding macro is BC_DIM_MAX. _SC_BC_SCALE_MAX indicates the maximum scale value allowed by bc(1); the corresponding macro is BC_SCALE_MAX. _SC_BC_STRING_MAX indicates the maximum length of a string accepted by bc(1); the corresponding macro is BC_STRING_MAX. _SC_COLL_WEIGHTS_MAX indicates the maximum numbers of weights that can be assigned to an entry of the LC_COLLATE order keyword in the locale definition file; the corresponding macro is COLL_WEIGHTS_MAX. _SC_EXPR_NEST_MAX is the maximum number of expressions which can be nested within parentheses by expr(1). The corresponding macro is EXPR_NEST_MAX. _SC_LINE_MAX The maximum length of a utility's input line length, either from standard input or from a file. This includes length for a trailing newline. The corresponding macro is LINE_MAX. _SC_RE_DUP_MAX The maximum number of repeated occurrences of a regular expression when the interval notation {m,n} is used. The value of the cor- responding macro is RE_DUP_MAX. _SC_2_VERSION indicates the version of the POSIX.2 standard in the format of YYYYMML. The corresponding macro is POSIX2_VERSION. _SC_2_DEV indicates whether the POSIX.2 C language development facilities are supported. The corresponding macro is POSIX2_C_DEV. _SC_2_FORT_DEV indicates whether the POSIX.2 FORTRAN development utilities are supported. The corresponding macro is POSIX2_FORT_RUN. _SC_2_FORT_RUN indicates whether the POSIX.2 FORTRAN runtime utilities are supported. The corresponding macro is POSIX2_FORT_RUN. _SC_2_LOCALEDEF indicates whether the POSIX.2 creation of locates via localedef(1) is supported. The corresponding macro is _POSIX2_LOCALEDEF. _SC_2_SW_DEV indicates whether the POSIX.2 software development utilities option is supported. The corresponding macro is POSIX2_SW_DEV. SUSv2 also lists _SC_PAGESIZE _SC_PAGE_SIZE The size of a page (in bytes). These values also exist, but may not be standard. _SC_PHYS_PAGES The number of pages of physical memory. Note that it is possible for the product of this value and the value of _SC_PAGE_SIZE to overflow. _SC_AVPHYS_PAGES The number of currently available pages of physical memory. RETURN VALUE
If name is invalid, -1 is returned, and errno is set to EINVAL. Otherwise, the value returned is the value of the system resource, 1 if a queried option is available, 0 if it is not, or -1 on error, and the variable errno is not changed. CONFORMING TO
POSIX.1. BUGS
It is difficult to use ARG_MAX because it is not specified how much of the argument space for exec() is consumed by the user's environment variables. Some returned values may be huge; they are not suitable for allocating memory. SEE ALSO
bc(1), expr(1), locale(1), fpathconf(3), pathconf(3) GNU
1993-04-18 SYSCONF(3)
All times are GMT -4. The time now is 03:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy