Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gracefully stop reading input in sub-process. Fixes #934.
This commit handles three major bugs with the current way of redirecting input from Leiningen to a sub-process: - The redirection is never stopped. This means that typing on the keyboard after a sub-process has finished will crash the thread redirecting data from *in* to the sub-process' input stream, as it is closed. - The redirection is buffered. This means that data intended to a subsequent sub-process may be sent to this sub-process instead. - The redirection blocks instead of busy waits. For the output streams, this is perfectly fine and the recommended approach to avoid wasting cycles. However, this has some issues when done to an input stream: If the sub-process finishes while the thread block waiting for a character, we will be unable to stop the thread before a character has been read. The consequence is that a character originally intended to the subsequent sub-process will be given to the previous process. These issues are solved by reading one byte at a time, busy wait on data and gracefully exit when the sub-process has ended (through a mutable variable/atom).
- Loading branch information