I've seen this Question.
It says that we could make a copy of both the file descriptors of stdin and stdout, in order for us to reopen them at a later stage in the program.
My questions:
- Could we open the file "/dev/tty" in O_WRONLY mode in order to reopen stdout?
- Is this the correct method of doing it?
- Is there any similar method to reopen stdin and stderr??
/dev/tty
will work, it wouldn't handle situation whenstd*
never were/dev/tty
, but rather was redirected to other process/file by calling shell. – keltarstd*
descriptors. Reading/writing to null wouldn't fail (but will go nowhere, of course), as opposed to invalid file descriptor. – keltar