Refactor to use dispatch_io for tasks, and wait for EOF

Hopefully resolves #139, #135, #161.

/cc @joshaber @keithduncan
I think we leak the stdin pipe by returning here, do we need to subscribe and immediately dispose to get it cleaned up?