# Linux Kernel Module Cheat
The perfect emulation setup to study and develop the <<linux-kernel>> v5.9.2, kernel modules, <<qemu-buildroot-setup,QEMU>>, <<gem5-buildroot-setup,gem5>> and x86_64, ARMv7 and ARMv8 <<userland-assembly,userland>> and <<baremetal-setup,baremetal>> assembly, <<c,ANSI C>>, <<cpp,C++>> and <<posix,POSIX>>. <<gdb>> and <<kgdb>> just work. Powered by <<about-the-qemu-buildroot-setup,Buildroot>> and <<about-the-baremetal-setup,crosstool-NG>>. Highly automated. Thoroughly documented. Automated <<test-this-repo,tests>>.

#### 27.4.3. fork

POSIX' multiprocess API. Contrast with pthreads which are for threads.

Example: userland/posix/fork.c

Sample native userland output on Ubuntu 19.04 at 762cd8d601b7db06aa289c0fca7b40696299a868 + 1:

    before fork before fork pid=13038 ppid=4805
    after fork after fork pid=13038 ppid=4805
    after (pid == 0) after (pid == 0) pid=13038 ppid=4805
    after fork after fork pid=13039 ppid=13038
    inside (pid == 0) inside (pid == 0) pid=13039 ppid=13038
    after wait after wait pid=13038 ppid=4805
    fork() return = 13039

Read the source comments and understand everything that is going on!

- getpid

- Fork bomb