This is the mail archive of the
mailing list for the glibc project.
Re: system and popen fail in case of big application
On Wed, Sep 12, 2018 at 9:29 AM, Zack Weinberg <firstname.lastname@example.org> wrote:
> I don't want to encourage people to use posix_spawn because
> posix_spawn is a badly designed API. It's difficult to use correctly.
> It's *tedious* to use correctly, which means people won't bother. It
> can't do everything you might want to do on the child side (witness
> the discussion of adding an extension to let it do chdir()). Its
> behavior in case of errors is underspecified. And it might be
> implemented in terms of fork, which means it doesn't guarantee to
> solve Sergey's problem.
I seem to be in agreement with Zack's eloquent post. From java's
point of view, we need to avoid the momentary doubling of memory
caused by fork()ing a huge process, and we need to be able to specify
a working directory for the child. One strategy is to use posix_spawn
to start a small helper process which then in turn execs the real
child after necessary set up (including chdir).