Email List: Xaustin-group-lX
[All Lists]

Re: sysconf() returning -1 ...

To: austin-group-l@xxxxxxxxxxxxx
Subject: Re: sysconf() returning -1 ...
From: Geoff Clare <gwc@xxxxxxxxxxxxx>
Date: Fri, 13 Nov 2009 11:34:42 +0000
References: <C9C53FF4-876F-4752-8661-9E0A9C73D851@sonic.net> <8CC31F094186303-130C-18F81@webmail-m026.sysops.aol.com> <EE36E1A3-CE68-4C46-8C71-B41DB6D7F37F@sonic.net> <A5D808CFA1E6CD459992A9B514111CDF0E11969D56@DEMCHP99E15MSX.ww902.siemens.net>
Schwarz, Konrad <konrad.schwarz@siemens.com> wrote, on 13 Nov 2009:
>
> Finally, the <limits.h> page says:
>
> To achieve maximum portability, an application should not require
> more resource than the Minimum Acceptable Value quantity. However, an
> application wishing to avail itself of the full amount of a resource
> available on an implementation may make use of the value given in
> <limits.h> on that particular implementation, by using the symbolic
> names listed below. [...] For these reasons, an application *may* use
> the fpathconf(), pathconf(), and sysconf() functions to determine the
> actual value of a limit at runtime. [emphasis mine]
>
> This makes sense for limits such as OPEN_MAX, the maximum number of
> files a process may have open at any one time. A simple application can
> work with the assumption that it can have open at most that many files,
> a more sophisticated one can query the operating system to see if it
> can open more.
>
> With limits that describe buffers (such as maximum line lengths or
> pathname lengths), the situation is the converse. Here, it is not
> the application requiring resources from the OS but the OS requiring
> resources (buffer space) from the application. In such a case, defining
> limits such as PATH_MAX as *lower bounds* makes little sense: when
> could a conforming application ever use this limit?

It makes sense in some contexts.  Consider an application that is
creating files.  To be fully portable in a simple way, it can limit
itself to creating files using pathnames shorter than _POSIX_PATH_MAX.
Alternatively it can query the {PATH_MAX} limit and use longer
pathnames on systems that accept them.

The same applies to LINE_MAX.  The original intention of LINE_MAX
(which came in from POSIX.2) was to allow applications to find out
what length of line it is safe for them to _write_ for use as input
to standard utilities.  In the fgets() example it is being used in
the opposite situation of an application reading lines.

-- 
Geoff Clare <g.clare@opengroup.org>
The Open Group, Thames Tower, Station Road, Reading, RG1 1LX, England

<Prev in Thread] Current Thread [Next in Thread>