[Issue 14770] std.process should use lightweight forks where available

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 30 15:01:33 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=14770

Hiroki Noda <kubo39 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kubo39 at gmail.com

--- Comment #4 from Hiroki Noda <kubo39 at gmail.com> ---
tl;dr: I think spawnProcess uses vfork internally iff Linux available.

* We must care about the process privilege, since if the parent process or
child process can change effective UID/GID, different privileged processes
shares memory.
* We must use _exit(2), same as before.
* signal handlers may rewrite global variables, so set SIG_DFL before vfork.
* Solaris has bug.
* Other platform planed(e.g, NetBSD has nice posix_spawn systemcall), but not
implement now.

Okay, I try to do this.

## References.

* posix_spawn(3) requires glibc 2.24+.
* posix_spawn(IEEE Std 1003.1-2008) cannot specifies working directory(chdir).
* http://www.tedunangst.com/flak/post/OpenBSD-and-vfork OpenBSD's vfork doesn't
share memory.
*
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9ff72da471a509a8c19791efe469f47fa6977410
glibc's posix_spawn uses clone(2) instead of vfork(2).
* https://bugs.ruby-lang.org/issues/11265#note-8 In Solaris, vfork causes
dynamic linker problem.
* https://github.com/golang/go/commit/9e6b79a5dfb2f6fe4301ced956419a0da83bd025
Go uses clone(CLONE_VFORK | CLONE_VM,..) Linux only.
* https://github.com/rust-lang/rust/pull/48624 Rust uses posix_spawn(3) on
FreeBSD/macOS/Linux.

--


More information about the Digitalmars-d-bugs mailing list