250 times 'fopen(...,"a")':errno 24 
Author Message
 250 times 'fopen(...,"a")':errno 24

Hi!
I have a daemon running on LINUX (2.0.30) that receives a lot of rekords
via SOCKET. It appends each rekord on a file:
'fopen(..., "a") ; fprintf(...) ; fclose(...);' (I need to do so).
When it execs 'fopen(...,"a")' for the 250th time it fails:
errno = 24 (EMFILE : Too many open files).

Do you know why?
Thanks in advance

Mimmo Ficara



Tue, 16 Nov 1999 03:00:00 GMT  
 250 times 'fopen(...,"a")':errno 24

You're probably not doing the fclose() correctly - check the
return code from the fclose.  My guess is that either the
FILE* is being clobbered, or you're not passing the correct
FILE*.  Does the fprintf() work?

Jim Dalsimer
==================================================

Quote:

>Hi!
>I have a daemon running on LINUX (2.0.30) that receives a lot of rekords
>via SOCKET. It appends each rekord on a file:
>'fopen(..., "a") ; fprintf(...) ; fclose(...);' (I need to do so).
>When it execs 'fopen(...,"a")' for the 250th time it fails:
>errno = 24 (EMFILE : Too many open files).



Tue, 16 Nov 1999 03:00:00 GMT  
 250 times 'fopen(...,"a")':errno 24



Quote:
>Hi!
>I have a daemon running on LINUX (2.0.30) that receives a lot of rekords
>via SOCKET. It appends each rekord on a file:
>'fopen(..., "a") ; fprintf(...) ; fclose(...);' (I need to do so).
>When it execs 'fopen(...,"a")' for the 250th time it fails:
>errno = 24 (EMFILE : Too many open files).

Most likely you aren't closing the files properly.

Quote:
>Do you know why?

Not without seeing the actual code you used. Post a minimal but complete
program that demonatrates the problem.

--
-----------------------------------------


-----------------------------------------



Thu, 18 Nov 1999 03:00:00 GMT  
 250 times 'fopen(...,"a")':errno 24

Quote:

> Hi!
> I have a daemon running on LINUX (2.0.30) that receives a lot of rekords
> via SOCKET. It appends each rekord on a file:
> 'fopen(..., "a") ; fprintf(...) ; fclose(...);' (I need to do so).
> When it execs 'fopen(...,"a")' for the 250th time it fails:
> errno = 24 (EMFILE : Too many open files).

> Do you know why?

<portable answer>
You're just running out of open files.

Either close files you're no longer using or increase the system limit
on open files.
</>

<platform specific answer>
This shell script for Linux will allow you an extra 256 open files per
process.   You can run it several times.  Eventually it will stop
working, perhaps when you run out of memory.   I have not tested it.

#!/bin/sh
filenr=`cat /proc/sys/kernel/file-nr`
filenr=`expr $filenr + 256`

filemax=`cat /proc/sys/kernel/file-max`
filemax=`expr $filemax + 1024`

echo $filenr > /proc/sys/kernel/file-nr
echo $filemax > /proc/sys/kernel/file-max
</>



Fri, 19 Nov 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ld.so.1: sh: fatal: libw.so.1: can't open file: errno=24

2. Displaying binary data as ascii "1"'s and "0"'s

3. Displaying binary data as ascii "1"'s and "0"'s

4. '.', '::", "->"

5. Reading Registry Error "__imp__RegQueryValueExA@24"

6. remove() vrs fopen("""w")

7. errno and fopen on Mac's

8. When to use "errno"

9. {'a','b','\0'} not equivalent to "ab"??

10. Errno 24 - Too many open files

11. fopen("myfile",r) or fopen("myfile",rb): pro/cons ?

12. "I don't like const"

 

 
Powered by phpBB® Forum Software