Questions: Shell Execution Model and Command Processing

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

When you run `sort < input.txt > output.txt`, which entity actually opens the files and connects them to the process's stdin and stdout?

AThe sort program reads the redirection syntax and opens the files itself
BThe shell opens the files and connects them to file descriptors in the child process before calling exec
CThe kernel parses the redirection operators and routes I/O automatically
DThe shell passes the filenames as command-line arguments to sort
Question 2 Multiple Choice

In the pipeline `cmd1 | cmd2 | cmd3`, when does cmd1 begin executing relative to cmd2 and cmd3?

Acmd1 runs to completion, then its output is passed to cmd2, which runs to completion, then cmd3 runs
BAll three commands are forked and run concurrently, connected by pipes the shell created
CThe shell runs cmd1 in the foreground and cmd2, cmd3 in the background sequentially
Dcmd3 starts first to prepare its input buffer, then cmd2, then cmd1
Question 3 True / False

Variable expansion (e.g., $HOME) and glob expansion (e.g., *.txt) happen inside the child process after exec() is called.

TTrue
FFalse
Question 4 True / False

A child process created by the shell inherits its parent's open file descriptors, including stdin, stdout, and stderr.

TTrue
FFalse
Question 5 Short Answer

Explain why quoting matters in shell commands. What specific shell behavior does quoting control, and what problem does it prevent?

Think about your answer, then reveal below.