spawn_sync: implement bindings
spawn_sync: closes pipes when killing inferior, cleanups

* If the child process is killed due to a buffer overflow or timeout,
  the stdio pipes are now closed immediately.

* Some logic was moved around and some methods/fields were renamed.