# Linux Kernel Module Cheat

#### 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