Slide 1

Slide 1 text

fork, vfork, posix_spawn 20210528

Slide 2

Slide 2 text

environment linux glibc2.24+ musl

Slide 3

Slide 3 text

fork create child process copy-on-write memory need same size memory per a child process POSIX.1-2001 https://git.musl-libc.org/cgit/musl/tree/src/process/fork.c

Slide 4

Slide 4 text

vfork same as fork share memory with child process sleep parent process -> run child process -> execve POSIX.1-2001(obsolate) removed POSIX.1-2008 https://git.musl-libc.org/cgit/musl/tree/src/process/vfork.c https://git.musl-libc.org/cgit/musl/tree/src/process/x86_64/vfork.s

Slide 5

Slide 5 text

posix_spawn fork-exec before glibc2.24, fork & vfork after glibc2.24, clone(2) https://git.musl-libc.org/cgit/musl/tree/src/process/posix_spawn.c

Slide 6

Slide 6 text

clone Linux-specific with flag CLONE_VFORK = vfork https://git.musl-libc.org/cgit/musl/tree/src/thread/clone.c https://git.musl-libc.org/cgit/musl/tree/src/thread/x86_64/clone.s

Slide 7

Slide 7 text

in Java usage example(shell command for chmod, etc) https://github.com/apache/hadoop/blob/ae9630f580d73e81042f3b8b2b337aba86130653/hadoop- common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java#L907 available linux & glibc2.24+ & JDK12 backported JDK11 https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8212828

Slide 8

Slide 8 text

other languages http://www.a-k-r.org/d/2014-09.html#a2014_09_06

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content