Build:
make
Run small demos:
make run
After fork, child gets a copy-on-write address space. Both see initial x, but later writes are independent.
See q1_fork_var.c
.
Parent/child share the same open-file description, so writes interleave and share the file offset.
See q2_open_fork.c
(generates q2_output.txt
).
Use a pipe: parent blocks on read until child signals. See q3_child_first_no_wait.c
.
Demonstrates execl/execle/execlp/execv/execvp/execvpe (if available). See q4_exec_variants.c
.
In parent, wait() returns child's PID and fills status; in child, wait() fails with ECHILD. See q5_wait.c
.
Wait for a specific child (or use WNOHANG). Useful with multiple children. See q6_waitpid.c
.
After closing fd 1, printf can't write to terminal; if a new file opens, it may reuse fd 1 -> output goes there.
See q7_close_stdout.c
.