githubnemo / CompileDaemon

Very simple compile daemon for Go
BSD 2-Clause "Simplified" License
1.61k stars 153 forks source link

Passes stdin to launched command #61

Closed pigfrown closed 3 years ago

pigfrown commented 3 years ago

This PR allows user to pass input to the launched command via stdin.

It gets a stdinPipe from the launched command, returns it from startCommand , and launches a goroutine that reads lines from os.Stdin and writes those lines to the launched command's stdinPipe.

Note: originally I tried to use bufio.Scanner instead of bufio.Reader to read user input, but had a strange issue where a numeric value (e.g. "2") would not get flushed to stdinPipe. I could type a string of dozens of numeric characters and it was only when I entered an alphabet letter that the full buffer would be written to stdinPipe. I gave up with this approach in the end but any insight as to why this happened would be appreciated!