joyent/node — Issue #2754: Add a `pty` option or equivalent to `cp.spawn()`
Author: TooTallNate
Created: 2012-02-14 23:12:54+00:00
State: open

My main concern is that there is no longer a way to spawn a child process where this would run successfully:

``` js
var assert = require('assert').ok;
var tty = require('tty');

assert(tty.isatty(0));
```

This is a problem for any node app trying to have its child processes generate ANSI color codes, as most well behaved programs test for that property. This used to be available I believe as `tty.open()` but was removed in `0.5.x`.

So I'm thinking adding a `pty: true` option to `cp.spawn()` would be a nice API. Would probably require libuv changes but this is a needed feature IMO.

``` js
var spawn = require('child_process').spawn;

var child = spawn('bash', [], { pty: true })
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
```

Thoughts?