Problem with system() when using lots of memory

Wietse Venema wietse at wzv.win.tue.nl
Fri Feb 22 07:15:00 AEST 1991


In article <1641 at brchh104.bnr.ca> david at marshal.gca-prism writes:

>We have been having problems using the system() function with programs
>that are particularly memory hoggish.  

Workaround: open a pipe to the shell before your process gets big:

	FILE *fp, *popen();
	 .
	 .
	if ((fp = popen("/bin/sh", "w")) == 0)
		oops!

Then write commands to the shell like:

	fprintf(fp, "%s\n", whatever...);
	fflush(fp);

Don't forget fflush() or things will reach the shell much later than intended.

	Wietse Venema



More information about the Comp.sys.sun mailing list