Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-16-2010, 08:27 PM   #1
LQ Newbie
Registered: Jun 2008
Posts: 20

Rep: Reputation: 0
C code fails on repeatedly opening /proc


I am trying to run my code repeatedly in a loop about 50 times for timing measurement. I have C code running on ubuntu 8 on a single processor, Intel x86. My code is something like this

for (loop =0;loop<=50;loop++)
// other operations

pDir = opendir("/proc");
while (pDir == NULL)
pDir = opendir("/proc");
// some computations


// other operations
} // end of loop
After about 28-29 times the loop stops executing. I initially had a return -1 if I got pDir == NULL. That caused my program to exit, and I dont want that. Any clues on why this happens, and how I can circumvent this?

Thanks for looking into this.
Old 01-16-2010, 08:48 PM   #2
LQ Newbie
Registered: Jun 2008
Posts: 20

Original Poster
Rep: Reputation: 0
Sorry about that. I found I had an unclosed file handle in my loop which was causing a crash. Now even 1000 times does not cause an exit.


code, directory, linux, opening

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
login repeatedly fails dla-nor Fedora 5 10-18-2008 07:12 AM
Installation of Ubuntu 8.04 fails repeatedly due to partitioning problems NGKEIB Linux - Newbie 7 07-13-2008 06:39 AM
LILO install fails repeatedly HippoGorgeous Linux - Newbie 1 07-01-2004 03:33 PM
/proc/acpi/... slow opening (tm) Linux - General 1 04-21-2004 07:43 AM
Mandrake 9.1 X boot manager fails repeatedly brainunused Mandriva 3 03-29-2004 01:00 PM

All times are GMT -5. The time now is 09:14 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration