On 15/10/2020 08:03, Michael Felt wrote:
$ exec </dev/null
$ exit
root@x065:[/data/prj/gnu/bash/bash-5.0.18]
```
As you can see by the return of the original PS1 - the sub-shell
(./bash) 'crashed' -- I did not type 'exit' - that is a result of the
'exec </dev/null' command the line before.
Upon running "exec </dev/null", the standard input is no longer attached
to your terminal emulator. Consequently, bash tries to read from
/dev/null, only to encounter EOF. As there is no further input to be
processed, it exits.
You can prevent this from happening by running a script, or by using the
-c option to convey the code. Doing so will launch a non-interactive
instance of bash that does not read commands from the standard input.
Incidentally, it is not a subshell but an ordinary subprocess.
--
Kerin Millar