vfork(2) System Calls Manual vfork(2) vfork - LIBRARY Standard C library (libc, -lc) #include pid_t vfork(void); glibc (. feature_test_macros(7)): vfork(): Since glibc 2.12: (_XOPEN_SOURCE >= 500) && ! (_POSIX_C_SOURCE >= 200809L) || /* Since glibc 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _BSD_SOURCE Before glibc 2.12: _BSD_SOURCE || _XOPEN_SOURCE >= 500 ( POSIX) vfork() fork(2) , , , vfork(), , pid_t, , vfork(), , vfork(), _exit(2) exec(3). Linux vfork(), fork(2), . , fork(2). vfork() -- clone(2). . , , , execve(2). vfork() fork(2) , , (, _exit(2) , , - ) execve(2). , . exit(3) ( , stdio(3) ), _exit(2). fork(2), , vfork(), (, , ); vfork() ( ). , (.. , execve(2)). Linux fork(2) , << >> (copy-on-write), , fork(2) -- , . , fork(2) , , exec(3). BSD vfork(), , , execve(2) . , . vfork() : , , . , vfork(), , fork(2), . , execve(2), . Some consider the semantics of vfork() to be an architectural blemish, and the 4.2BSD man page stated: "This system call will be eliminated when proper system sharing mechanisms are implemented. Users should not depend on the memory sharing semantics of vfork as it will, in that case, be made synonymous to fork." However, even though modern memory management hardware has decreased the performance difference between fork(2) and vfork(), there are various reasons why Linux and other systems have retained vfork(): o , vfork(). o vfork() can be implemented on systems that lack a memory-management unit (MMU), but fork(2) can't be implemented on such systems. (POSIX.1-2008 removed vfork() from the standard; the POSIX rationale for the posix_spawn(3) function notes that that function, which provides functionality equivalent to fork(2)+ exec(3), is designed to be implementable on systems that lack an MMU.) o vfork() ( /proc/sys/vm/overcommit_memory proc(5)) ( , ). fork(2) ( ) (OOM). , Linux fork, pthread_atfork(3), NPTL vfork(). fork , LinuxThreads. (. pthreads(7) Linux.) vfork() clone(2) flags: CLONE_VM | CLONE_VFORK | SIGCHLD None. 4.3BSD; POSIX.1-2001 ( ). POSIX.1-2008 vfork() . The vfork() system call appeared in 3.0BSD. In 4.4BSD it was made synonymous to fork(2) but NetBSD introduced it again; see . In Linux, it has been equivalent to fork(2) until Linux 2.2.0-pre6 or so. Since Linux 2.2.0-pre9 (on i386, somewhat later on other architectures) it is an independent system call. Support was added in glibc 2.0.112. CAVEATS , . : , ( vfork()), , (, , ). vfork() , . , . , ( setuid(2) ), , . , , , vfork(). vfork() , (, , dlopen(3)). , mmap(2) , . . BSD : << , vfork(), SIGTTOU SIGTTIN, ioctl , >>. . clone(2), execve(2), _exit(2), fork(2), unshare(2), wait(2) Azamat Hackimov , Dmitriy Ovchinnikov , Dmitry Bolkhovskikh , Katrin Kutepova , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . vfork(2)