-
For
>>
, the answer is similar to the >
redirection, except that the
file is opened with the flags [O_WRONLY; O_APPEND; O_CREAT]
.
- For
2>
, the answer is similar to the >
redirection, except that
dup2 fd stderr
is executed instead of dup2 fd stdout
- For
2>1
, we must call dup2 stderr stdout
before executing
the command.
- For
<<
, the shell sh
must create a temporary file in
/tmp
containing the lines that follow <<
and execute the
command with its standard input redirected from this file. Another
solution is to connect the command’s standard input to the output of a
pipe and let a child process write the lines following <<
on the
input of that pipe.
* * *