Stdin fixes

Mainly, this fixes #476 (further comments in commit). The other two I stumbled upon while reading the relevant code.

The solution with `/dev/stdin` works nicely on my system, but I'm not sure how portable it (or ag for that matter) is.