Date:        Tue, 8 Jun 2021 16:15:12 +0000
    From:        "Nia Alarie" <n...@netbsd.org>
    Message-ID:  <20210608161512.1d7c3f...@cvs.netbsd.org>

  | vfork.2: recommend posix_spawn instead

You might want to reconsider the wording there, posix_spawn() is
an alternative to [v]fork() + exec*().   Not just vfork().

It should, when it is workable for the application, make things
faster, while also avoiding the vfork() perils.   But only when
it works -- after a vfork() the child can do anything (it should
avoid touching its parent's state, but it can) posix_spawn() isn't
nearly that general, it just handles the most common things apps
are likely to want to do between the fork() and exec().  Perhaps
most notably, it has no notion of (with err checking omitted):

        if (fork()) { parent_code(/* do a waitpid() first */); }
        else if (fork()) { exit(0); }
        else { child_code() /* often ending with execX() */ }

when one wants to create an orphan (nothing that cannot be waited upon).

kre

Reply via email to