In the past I have used a combination of a timeout and a black that the user sets to explicitly say, "look for STDIN", sort of like some *nix utilities use the lone "dash" (
-) (e.g.,
tar, etc). Also I found this solution (
stackexchange) that is not my solution but demonstrates using a time out with the read.