Unfortunately I've had no luck figuring this out, as everything I find is just on the syntax of redirection, or shallow information about how redirection works.
What I want to know is how bash actually changes
stderr when you use pipes or redirection. If for example, you execute:
ls -la > diroutput.log
How does it change
I assume it works like this:
- Bash runs
fork(2)to create a copy of itself
- Forked bash process sets it's
diroutput.logusing something like
- Forked bash process runs
execve(2)or a similar exec function to replace itself with
lswhich now uses the
stdoutsetup by bash
But that's just my educated guess.