Extract reading boilerplate into rstream.c module

The `RStream` class hides the differences between files and other types of
streams with a simpler, general-purpose API for performing non-blocking reads
with libuv. Most of the code was adapted from input.c.
Refactor job control module to use RStream class