errno from fopen()

M

Michael McGarry

Hi,

How do I interpret errno from fopen()? errno = 24 in my case.

Thanks for any help,

Michael
 
M

Michael McGarry

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.

Michael
 
G

Gordon Burditt

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.

Gordon L. Burditt
 
B

Ben Pfaff

Michael McGarry said:
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.

The values of errno vary from system to system.
Use strerror() or perror().
 
S

SM Ryan

# 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.
....
 
F

Flash Gordon

Michael said:
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.

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.
 
M

Michael McGarry

It was a case of file descriptor leak.

I will use strerror to get the error message.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

errno 4
fopen 20
Socket Programming (connect() returns errorno = 38) 5
fopen() questions 17
Linux: using "clone3" and "waitid" 0
&errno, sizeof errno 20
Adding adressing of IPv6 to program 1
fopen question 7

Members online

Forum statistics

Threads
474,173
Messages
2,570,938
Members
47,474
Latest member
VivianStuk

Latest Threads

Top