>How do I interpret errno from fopen()? errno = 24 in my case.
On my system (FreeBSD), that error code is 'too many open files'.
In programs, it's more friendly to call strerror(errno) and print
the string in an error message, or use perror(), than to print errno
in decimal.
Other ways to look up error codes include reading the <errno.h>
header file (on systems where it really is a file; it doesn't have
to be) and running "man errno".
Note that your error code refers to hitting a *per process* open
file limit, not a *system wide* open file limit. Do you keep opening
files and forget to close them ("file descriptor leak")? The
stingiest system I've seen with open files per-process allows 20
(including stdin, stdout, and stderr) and some allow a few thousand,
although if very many tried that, they'd hit the system-wide limit.
"Michael McGarry" <michael.mcgarr y@gmail.com> writes:
[color=blue]
> I figured this out. errno = 24 means too many files open. Where can I
> find documentation on errno values? I could not find it in
> Harbison/Steele.[/color]
The values of errno vary from system to system.
Use strerror() or perror().
--
Just another C hacker.
"Michael McGarry" <michael.mcgarr y@gmail.com> wrote:
# Hi,
#
# How do I interpret errno from fopen()? errno = 24 in my case.
Does perror give a meaningful message? You might see if error
numbers are listed in errno.h. On Unix, you can do
man 2 intro
....
24 EMFILE Too many open files. <As released, the limit on the number of
open files per process is 64.> Getdtablesize(2 ) will obtain the
current limit.
....
Michael McGarry wrote:[color=blue]
> Hi,
>
> I figured this out. errno = 24 means too many files open. Where can I
> find documentation on errno values? I could not find it in
> Harbison/Steele.[/color]
The only place is in documentation covering your specific system, and we
don't cover system specifics here. You may however find the standard
functions perror and strerror of use since they will allow you to output
in the manner of your choosing an error message that expands on the
value of errno.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Comment