Skip to main content
added 75 characters in body
Source Link
Tim
  • 106.9k
  • 234
  • 651
  • 1.1k

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.

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.

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.

Source Link
Tim
  • 106.9k
  • 234
  • 651
  • 1.1k

How can we disconnect a file descriptor from any file?

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.