Using vfork() in do_system() instead of fork()

Mike Frysinger vapier@gentoo.org
Tue Jun 23 18:38:00 GMT 2009


On Tuesday 23 June 2009 14:16:02 David Wuertele wrote:
> > Linux implements copy-on-write, therefore after the fork you shouldn't
> > be using any more memory (modulo the new structures allocated by the
> > kernel). Are you actually seeing memory usage double after the fork? I
> > think your problem is elsewhere.
>
> I don't have direct evidence that the memory usage doubles, but system()
> only fails if my app has consumed more than half of physical memory.
>
> One test I did was to write a program that allocates and touches more and
> more memory, while running system() and my replacement of glibc's
> system() that uses vfork() instead of fork().  After the test program
> allocates about half of remaining memory, the standard system() starts
> returning -1, but my vfork() implementation continues to work right up
> until there's really nothing free.

since there's pretty much no chance of do_system() changing, why not use your 
simple wrapper.  the amount of code needed to do vfork+exec on a string is 
pretty small.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/libc-help/attachments/20090623/e1041dfa/attachment.sig>


More information about the Libc-help mailing list