Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.

Process Model

Why does a Unix shell start processes? How many processes are started?

Related: Interpreter State. These two docs are the missing documentation for shell!

Table of Contents
Shell Constructs That Start Processes
Pipelines
Command Sub d=$(date)
Process Sub <(sort left.txt)
Async - fork or sleep 2 &
Explicit Subshell - forkwait or ( echo hi )
Process Optimizations - noforklast
Process State
Redirects
Builtins
wait
fg
bg
trap
Appendix: Non-Shell Tools

Shell Constructs That Start Processes

Pipelines

Functions Can Be Transparently Put in Pipelines

Implicit subshell:

{ echo 1; echo 2; } | wc -l

A SubProgramThunk is started for the LHS of |.

Command Sub d=$(date)

d=$(date)   

Process Sub <(sort left.txt)

diff -u <(sort left.txt) <(sort right.txt)

Async - fork or sleep 2 &

Explicit Subshell - forkwait or ( echo hi )

Explicit Subshells are Rarely Needed.

Process Optimizations - noforklast

Bugs / issues

Oils/YSH specific:

Process State

Redirects

Builtins

wait

fg

bg

trap

Appendix: Non-Shell Tools

Generated on Sun, 25 Aug 2024 12:30:01 -0400