Paste a C program that uses fork(). Every process is simulated, so you see the process tree, what each process prints, and the full output.
Terminal: printf output is flushed at every newline, like running ./a.out directly.
This is one possible order. Processes run at the same time, so the real order can change from run to run; the lines and their counts do not. Underline colour shows which process printed each piece.
| PID | Parent | Created at | Printed | Exit |
|---|
What is simulated: fork, wait, waitpid, exit, atexit, sleep, getpid, getppid, exec* (shown as a note), printf family with real C formatting, scanf, malloc/free, arrays, pointers, structs and unions. Stdout buffering is modelled, so text printed without a newline before fork() is copied into the child, just as on a real machine. Infinite loops stop after a step limit. This is a teaching simulator; for exact results on edge cases, compile with gcc.