Goal: Run a single external command from your shell prompt.
fork()
, execvp()
, waitpid()
fork()
and process IDsargv[]
→ executecd
(chdir()
), exit
strtok
or manual parsingGoal: Handle <
, >
, >>
redirections.
0
, stdout = 1
, stderr = 2
open()
, close()
from <fcntl.h>
O_RDONLY
, O_WRONLY | O_CREAT | O_TRUNC
, O_WRONLY | O_CREAT | O_APPEND
dup2()
to redirect stdin/stdout before execvp()
<
, >
, >>
from argv[]
, open the files, apply dup2()
Goal: Support cmd1 | cmd2 | cmd3
pipe()
returns two fds: read end and write enddup2()
to attach pipe ends to stdin/stdout