This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]