Created by: gaearon
Maybe fixes #1200 (closed). Apparently spawn sometimes fails synchronously and sometimes fails in an event emitter. I restructured the code a tiny bit.
spawn