Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!mips!daver!ditka!mcdchg!tellab5!wheaton!stefan From: stefan@wheaton.UUCP (Stefan Brandle ) Newsgroups: comp.unix.questions Subject: Re: Making a popen replacement with vfork() Message-ID: <2025@wheaton.UUCP> Date: 4 May 90 13:04:08 GMT References: <6830@jarthur.Claremont.EDU> Reply-To: stefan@wheaton.UUCP (Stefan Brandle ) Organization: Wheaton College, IL Lines: 26 In article <6830@jarthur.Claremont.EDU> jseidman@jarthur.Claremont.EDU (James Seidman) writes: >I'm working on a program which uses popen() several times to run on an >ULTRIX workstation. The program's image is very large, occupying almost 50% >of the computer's core memory. My problem is that every time a popen() >occurs, the system grinds to a halt. What I suspect is happening is that >popen() calls fork(), fork() tries to copy the entire program image, and >therefore a lot of swapping has to occur. vfork might do nicely. Another possible approach is to have a small stub program that sets up all necessary pipes, file descriptors, then forks off and execs the pipe-children and the parent execs the real program you want to run. That way the program that is getting duplicated would actually be quite small. This works ok if you have a relatively small number of children and know the number in advance. If not, you may need to do it by having a process that acts as a `daemon' and communicates with your main program by way of sockets or your favorite IPC method, and gets told by the main program what to popen/fork/exec, and then sends the results back to the main program. Of course, if vfork works right, that's an easier solution. Stefan Brandle -- ---------------------------------------------- MA Bell: (708) 260-5019 --------- Stefan Brandle UUCP: ...!{obdient,uunet!tellab5}!wheaton!stefan Wheaton College or stefan@wheaton.UUCP Wheaton, IL 60187 "But I never claimed to be sane!"