This happens on every distro I've tried:
$ cat | bash -i bash-3.2$ ls foo bar bash-3.2$
And now the session is hung. Ie, you get one command and then you pretty much have to close the terminal window. SIGTERM (aka ^C) is caught by bash but it won't get you back to a working shell.
I'm guessing it has something to do with the
-i causing bash to fight with cat for control of the tty, but I can't find anything definitive. Can anyone explain what's going on? And how do I automate input to a program that's running
execlp("/bin/bash", "bash", "-i") without hanging? Do I have to write an
expect-like program that handles tty vagaries?