Too many open files - C++ on Unix


 
Thread Tools Search this Thread
Top Forums Programming Too many open files - C++ on Unix
# 1  
Old 04-27-2009
Too many open files - C++ on Unix

Hi all,

My requirement is like this:
I have list of numbers, i need to get the data related to those numbers from database and write the information into a file .
I am using open function to write data related to one number. Close the file. Get the next number ,write data and close again.
I am using this logic as my file depends on some information that is being extracted for number. So every time, i prepare the file name (with that information: say xxx) and open the file in append mode. So if the extracted information (xxx) is already existing, this data will be appended to the existing file. Otherwise a new file will be created.

As per my understanding, as i am closing this file everytime, ideally speaking i will have only one open file at any time. But i am getting "Too many open files" errors.

Could some one please help me in resolving this issue.

Thanks in advance
Parvat
# 2  
Old 04-27-2009
I can't read your code from here. Seeing the code would probably be helpful. Please use code tags when you post it, [ code ] stuff [ /code ] but without the extra spaces in the tags.
# 3  
Old 04-28-2009
code sample

Here is the code that i am using:
I am giving the piece of code which is giving me this error. Thanks
Code:
ofstream feedin;

main() {
// for each account do the following
sprintf(file_name_var, "%s_%s_%s_%s_%s.dat",ProcessId, StartDate, StartTime, stmt_date, ssa_shrt_descr); // ssa_shrt_descr is derived from account.
feedin.open(file_name_var, ios::out | ios::app);
if (feedin == NULL){
    cout << "ERRS: Open Error - " <<  strerror(errno) << endl;
}
FormatFile(account, feedin);
feedin.close();
}


Last edited by Yogesh Sawant; 04-28-2009 at 04:19 PM.. Reason: added code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to open webpage through UNIX?

Hi friends, I have UNIX (HP-UX) server. I want to open a webpage (lets say www.unixhelp.com) on this webpage there is one checkbox. I just need to check it. and click on save. Its just take a half a minute to do so in windows system. But I am wondering if this is possible though UNIX server.... (3 Replies)
Discussion started by: Nakul_sh
3 Replies

2. Fedora

Is UNIX an open source OS ?

Hi everyone, I know the following questions are noobish questions but I am asking them because I am confused about the basics of history behind UNIX and LINUX. Ok onto business, my questions are-: Was/Is UNIX ever an open source operating system ? If UNIX was... (21 Replies)
Discussion started by: sreyan32
21 Replies

3. UNIX for Dummies Questions & Answers

Vi editor will not open new to UNIX. help please.

vi: syntax error at line 1: `)' unexpected when I try to vi into the /etc/vfstab, the return gives me the above error. how can resolve this so that I can have access into vi. (6 Replies)
Discussion started by: dovestar
6 Replies

4. Shell Programming and Scripting

open files

I want to open a file and edit it using vi However, i dont want to open directories or binary files. how can i do this? Right now it opens all files without caring echo "please enter a file to edit in Vi" read file if then (2 Replies)
Discussion started by: icelated
2 Replies

5. Filesystems, Disks and Memory

Unix Sco Open Server, Windows Computers Problem Access Unix Shared Files Help!!!!!

Hello Moto I hope someone can help We's here at work, have a unix box with sco openserver 5 on it, so it has a nice gui interface.. and also a fair few windows computers.. a system admin guy b4 me, has set up a user called neil, which can, when u try to access the unix box using windows... (2 Replies)
Discussion started by: haggo
2 Replies

6. UNIX for Advanced & Expert Users

Too Many files open

Hi , We are using a Tool which runs on Unix Server. Have a Event which have some join operation and tries to open files depending on the join operation. So get the error config/variants/orcl6/partitions/ml6/data/ap_PCardMap.csv (Too many open files) Can someone please... (3 Replies)
Discussion started by: shashank_recj
3 Replies

7. Shell Programming and Scripting

open unix file in windows

Hi, I have a text file in unix. i am trying to give a link in Internet explorer to that file. If i click on the link in Internet Explorer page then it should display the text from file in unix. is that anyway possible.... i am trying it for past 2 days....if i find a way out i will... (3 Replies)
Discussion started by: ganesh
3 Replies

8. UNIX for Advanced & Expert Users

Proprietary vs. open Unix

Howdy all, I've used various applications in the past that ran in unix and windoze and unfortunately several of those programs are migrating to a windoze only environment so management is bagging the proprietary unix boxes in the process. AArrgggghh So here's my question for all you serious... (3 Replies)
Discussion started by: bulletbob
3 Replies

9. UNIX for Dummies Questions & Answers

Difference between UNIX operating system and Unix Open Server

Hi, I recently joined this forum and new to UNIX. Is there any difference between UNIX operating system and UNIX open server? Please explain. (1 Reply)
Discussion started by: Manjit
1 Replies
Login or Register to Ask a Question