david@marshal.gca-prism (David Oskard) (02/14/91)
We have been having problems using the system() function with programs that are particularly memory hoggish. Any call to system() after a large portion of the machine's memory has been allocated causes a return with a value of -1 and errno set to 12 (out of memory). Even just giving a simple command like system("echo aaaaaaaargh") doesn't work. Is there an easy way to solve this? Of course, the best solution would be to reduce the program's memory requirements, but is there any other way to get it to work? Please reply to me via Email as I have limited net access. Thanks in advance! David Oskard @ PRISM Interactive Products Glen Ellyn, IL gcapsm!david@uunet.uu.net or uunet!gcapsm!david or oskard@cs.umass.edu <<<--this one will definitely work
wietse@wzv.win.tue.nl (Wietse Venema) (02/22/91)
In article <1641@brchh104.bnr.ca> david@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