473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

popen cannot allocate memory

Hi all, i'm having a really nasty problem with popen.
I have the following code :
---------------------
....
FILE *PD;
....
sprintf(fname[i],"/usr/bin/gzip -dc %s/%s",dirname,dp->d_name);
....
if((PD = popen(fname[i], "r"))==NULL){
fprintf(stderr,"%d: Failed opening pipe to %s\n",errno,fname[file]);
exit(-1);
}
....
pclose(PD)
....
---------------------

Now the popen is in a cycle and should open about 250 files in the same
dir.
The weird thing is that it always stops at file 100, no matter which
file it is, and I get the following
error message:
"12: Failed opening pipe ..."
doing perror 12 i get:
"Error code 12: Cannot allocate memory"

I don't understand why popen cannot allocate memory - any suggestion?
Thanks!

rveloso

Apr 4 '06 #1
1 6445
"rveloso" <rv******@gmail.com> writes:
Hi all, i'm having a really nasty problem with popen.
I have the following code :
---------------------
...
FILE *PD;
...
sprintf(fname[i],"/usr/bin/gzip -dc %s/%s",dirname,dp->d_name);
...
if((PD = popen(fname[i], "r"))==NULL){
fprintf(stderr,"%d: Failed opening pipe to %s\n",errno,fname[file]);
exit(-1);
}
...
pclose(PD)
...
---------------------

Now the popen is in a cycle and should open about 250 files in the same
dir.
The weird thing is that it always stops at file 100, no matter which
file it is, and I get the following
error message:
"12: Failed opening pipe ..."
doing perror 12 i get:
"Error code 12: Cannot allocate memory"

I don't understand why popen cannot allocate memory - any suggestion?


popen() is not a standard C function.

Some systems may impose limits on the number of files you can open
simultaneously. It's not clear from your code fragment whether you
close each file before opening a new one.

Both topics are more appropriate for comp.unix.programmer.

When you post there, it would be a good idea to post a complete,
self-contained program that illustrates the problem.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Franklin Lee | last post by:
Hi All, I use new to allocate some memory,even I doesn't use delete to release them. When my Application exit, OS will release them. Am I right? If I'm right, how about Thread especally on...
3
by: jcgeorge | last post by:
I am getting this: RETCODE : ZRC=0x8B59000D=-1957101555=SQLKF_NOMEM_BUFFER_HEAP "No memory available in 'FCMBP Heap'" DIA8300C A memory heap error has occurred. and this FUNCTION: DB2 UDB,...
17
by: bastiaannaber | last post by:
I am trying to write a program which uses popen but I have a problem. I want to detect if the program I call with popen has ended. For example: #include <stdio.h> #include <sys/types.h>...
4
by: agarwalpiyush | last post by:
Hello, I am going nuts with trying to get the following to work: This is what I intend to do: I have a line in /etc/syslog.conf which I need to delete based on ip-address provided to me in a...
2
by: Maarten van Veen | last post by:
A long story made short, I've build a python/cgi website consisting of two pages. Page1 has a html form in which you can input a series of queries. Then via Popen it starts a pythons search script,...
2
by: CFAN | last post by:
Why the disk space keep on decreasing,is that due to use popen()? I have wrote a monitor program to ensure my program on working by using popen to use 'ps' command, but the disk space keep on...
12
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
1
by: EEK | last post by:
Hello, My goal is to start and stop separate Linux processes from a python program by specific PID. The output of these processes needs to have their stderr and stdout piped to a particular...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.