In a process using lots of memory, how can I spawn a shell without a memory-hungry fork()?

Posted by kdt on Stack Overflow See other posts from Stack Overflow or by kdt
Published on 2010-04-29T08:06:32Z Indexed on 2010/04/29 8:17 UTC
Read the original article Hit count: 187

Filed under:
|
|
|
|

On an embedded platform (with no swap partition), I have an application whose main process occupies most of the available physical memory. The problem is that I want to launch an external shell script from my application, but using fork() requires that there be enough memory for 2x my original process before the child process (which will ultimately execl itself to something much smaller) can be created.

So is there any way to invoke a shell script from a C program without incurring the memory overhead of a fork()?

I've considered workarounds such as having a secondary smaller process which is responsible for creating shells, or having a "watcher" script which I signal by touching a file or somesuch, but I'd much rather have something simpler.

© Stack Overflow or respective owner

Related posts about c

    Related posts about shell