HomeFreeBSD

Don't abuse vfork()

Description

Don't abuse vfork()

According to POSIX.1, "vfork() has the same effect as fork(2),
except that the behavior is undefined if the process created by vfork()
either modifies any data other than a variable of type pid_t
used to store the return value from vfork(), [...],
or calls any other function before successfully calling _exit(2)
or one of the exec(3) family of functions."

These do all three, and work by pure chance
(or maybe they don't, but we blisfully don't know).
Either way: bad idea to call vfork() from C,
unless you're the standard library, and POSIX.1-2008 removes it entirely

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12015

Details

Provenance
наб <nabijaczleweli@nabijaczleweli.xyz>Authored on May 8 2021, 11:17 AM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on May 21 2021, 5:16 PM
Parents
rG5da6353987cc: libzfs: run_process: don't leak fd on reopen failure
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG93ef500388db: Don't abuse vfork() (authored by наб <nabijaczleweli@nabijaczleweli.xyz>).May 21 2021, 5:16 PM