Co Child Process
Spawn a child process using co
. Kind of like exec
, except you can write to stdin
and there aren't as many options like timeout or encoding.
Example
Minify a Javascript in a child process. Useful when the JS files are large and you don't want uglifyjs blocking the event loop.
var fs = var co = var spawn = // resolve the location of the binaryvar uglifyjs = require
API
var output = spawn(command, [args], [options])
A wrapper around child_process.spawn. The arguments are simply passed and are not touched.
Output is always a string, for now.
var output = spawn(args...).pump(stream)
Pump a stream into the child process' stdin
. Kind of like .pipe()
but in the opposite direction.
Must be called on the same tick.
var output = spawn(args...).end(body)
Write a buffer or string body to stdin
.
var out =
Must be called on the same tick.