Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libc/sys



    Date:        Tue, 8 Jun 2021 16:15:12 +0000
    From:        "Nia Alarie" <nia%netbsd.org@localhost>
    Message-ID:  <20210608161512.1D7C3FA95%cvs.NetBSD.org@localhost>

  | 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



Home | Main Index | Thread Index | Old Index