In bash we can create a connection between a file descriptor and a file, e.g. by
exec > /path/to/myfile
which connects fd 1 to the file.
I was wondering how we can disconnect a fd from any file connected to it, so that the fd isn't connected to any file? Note that /dev/null
and /dev/tty
are files.
Thanks.
My purpose is to figure out Does a shell automatically connect file descriptors 0, 1 and 2 to its controlling terminal?, by disconnect fd 0, 1 and 2 in bash, before running bash
in the same bash shell.
bash
in the same bash shell. – Tim May 29 '18 at 02:54