How do I make a background process block for input a la the shell's `bg` command?
问题 I am implementing my own fragment of code for a security control purpose. It normally runs in the background but on a timeout needs to take over the current terminal, display a message, collect user input, and react to the user input. Waiting for the timeout is easy. Collecting user input while sleep is the active program is easy. Preventing the shell from stealing the user input I just tried to collect is not so easy. I am reasonably convinced that "What if two programs did this?" doesn't