This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Using vfork() in do_system() instead of fork()
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: David Wuertele <dave+libc-help at wuertele dot com>
- Cc: libc-help at sourceware dot org
- Date: Tue, 23 Jun 2009 13:19:46 -0400
- Subject: Re: Using vfork() in do_system() instead of fork()
- References: <684851e60906231011n7cdca465kd2ca9d6262483e7e@mail.gmail.com>
On Tue, Jun 23, 2009 at 1:11 PM, David
Wuertele<dave+libc-help@wuertele.com> wrote:
> In glibc, sysdeps/posix/system.c:do_system() implements the system()
> command with fork() and execve(). ?This causes a problem for my
> embedded product because the fork() copies the process VM doubling the
> used memory and tirggering the OOM killer. ?This would normally not be a
> problem, but my team has decided for various reasons to use
> /proc/sys/vm/overcommit_memory == 0.
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.
Using vfork() to implement system() violates POSIX which requires that
it operate as if fork() were called followed by execl(). It likely
needs to use fork() to setup blocked signals etc.
Cheers,
Carlos.