On Sun, 13 Oct 2024, 17:15 Oğuz, <oguzismailuy...@gmail.com> wrote: > On Sun, Oct 13, 2024 at 3:18 AM Chet Ramey <chet.ra...@case.edu> wrote: > > You have two processes fighting over stdin. > > Why though? Can't bash just close the procsub's stdin when `:' returns? >
Of course not. The operating system won't let processes meddle with each other's internals. And even if you can, you shouldn't. While there are exemptions for debuggers, they can't run without extra metadata for the program in question (and preferably its source code). In particular, there's no exemption for when one is a shell (like Bash) and the other is a program it's launched. On some operating systems there are extremely contrived ways to achieve this, but then you face a far more fundamental problem: you can't tell whether or not stdin has been replaced by the program itself, whereupon you would wind up closing something that should be left alone. -Martin