stdin, stdout and stderr are shared between?
I am trying to understand the behavior of the three streams - stdout , stdin and stderr . I couldn't get the answer from any textbook, so I came here. I know that these three are stored in file descriptor table with file descriptors 0 (stdin), 1 (stdout) and 2 (stderr). I am also aware that these are not merely file descriptors but I/O streams which can be redirected. Ok, so how about sharing? Consider the three cases: When a fork() is called : The child process and parent process shares file descriptors, but do they have the same stdin, stdout and stderr ? When a thread is created : Threads