10-24-2002
I'm not sure why you think fcntl() fits into this. To close an fd you use close().
It is absolutely required that a daemon close fd's 0, 1, and 2. After that, as the lawyers say, "reasonable minds may disagree". In the days when we were limited to 64 fd's, it was reasonable to simply loop invoking close() on them all. If I was to write a daemon, yes I guess that I would use get getconf(_SC_OPEN_MAX) to get the max possible fd and loop invoking close() on every last one. This could be thousands of close() calls that aren't needed, but close() fails very quickly when invoked against a non-open fd.
If they are closing stdin, stdout, and stderr, I would have to say that their stance is reasonable. But I do believe they would have a difficult time producing any language in posix that supports them. The posix standard is on-line and we have a link to it on our home page. Exactly which section do they cite?
It should be very easy to solve your problem though. Can't you change the app server to not leave extra fd's open?
Or if this daemon is called, say, daemonx, just write a program that closes all fd's and then exec()'s daemonx. Call your program pre_daemonx. Have your app server call pre_daemonx.
Is the name "daemonx" hard-coded into an unchangable app server? No problem. Rename "daemonx" to "real.daemonx" and call your program "daemonx".
Whichever path you take here, fixing this should be a 10 minute problem.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Is there any commands in UNIX, like isopen(),isclose() to know whether a file has been opened for read/write purpose.?
Thanks (3 Replies)
Discussion started by: Pal
3 Replies
2. Solaris
Hi
I have a script to remove log files when it reaches %70 usage in order to descending order of dates. But sometimes it happens to remove open - being processes files , so makes them unlinked from the directors and results them disappeared.
How can I solve this problem , simple scenario I... (9 Replies)
Discussion started by: xramm
9 Replies
3. UNIX for Advanced & Expert Users
I am having a client/server application which will download files from server. If server has directories, it will create directories/sub directories and then download files. In this process, I observed that number of open files are more than 400 (which is approxmately same as number of dir/subdir... (1 Reply)
Discussion started by: satyam90
1 Replies
4. Windows & DOS: Issues & Discussions
I'm trying to setup a cron job for my brother that goes out to the web and retrieves an excel file and overwrites the existing copy on his desktop. The problem I'm facing is I have to kill the process (excel.exe) if the file is open while the batch file runs, otherwise, it will create another copy... (2 Replies)
Discussion started by: quattro20v
2 Replies
5. Solaris
Hi
want to know what file (descriptor+filename+socket) is being accessed by particular process on solaris.
Purpose : while running perf. test, needs to find where is the bottleneck.
We are providing concurrnet load for around 1 hr and needs to capture data related to file usage pattern... (1 Reply)
Discussion started by: raxitsheth
1 Replies
6. Programming
can someone provide an example, where if the parent process quits for any reason, then the child process will also close? (3 Replies)
Discussion started by: omega666
3 Replies
7. IP Networking
Hi,
I have read some forum theads about the open and close ports. some points are clear and it is not working on my machine or something am i missing?
I have commented out a port /etc/services, one application uses
then when i use the telnet <hostname> <port_blocked> it shows connected..... (1 Reply)
Discussion started by: balamv
1 Replies
8. UNIX for Advanced & Expert Users
Can any help me in finding the way to close opened file descriptor in Solaris ,without killing process. As accidently a file was removed which was opened by a process.
Much thanks in advance :) (11 Replies)
Discussion started by: nitj
11 Replies
9. Shell Programming and Scripting
I would like to create the following script:
run a python script with setsid
python may or may not fail with exception
check if all of the group processes were terminated correctly
if not, kill the remaining processes
How can I do that?
Thanks a lot (3 Replies)
Discussion started by: ASF Studio
3 Replies
10. Shell Programming and Scripting
Hi Gurus,
I have an input like the one below. What i wanted to achieved is to create a select statement based from that information
INPUTInsert into table_name (col1,col2,col3,col4,col5,DATE1,DATE2,col6,col7,col8,col9,col10,col11) values (6752,14932156,24,'ALL','Staff',to_date('04/17/2017... (6 Replies)
Discussion started by: ernesto
6 Replies