gf3/sandbox — Issue #15: Error: write EPIPE 
Author: DmitryKoterov
Created: 2012-01-24 15:14:12+00:00
State: open

The following script (run_stdin.js):

```javascript
var Sandbox = require('./sandbox/lib/sandbox');
var s = new Sandbox();
var code = '';
var stdin = process.stdin;
stdin.resume();
stdin.setEncoding('utf8');
stdin.on('data', function(data) { code += data });
stdin.on('end', function() {
s.run(code, function(output) {
console.log(output);
});
});
```javascript

The following error when I run it:

```
# echo "1+1" | node run_stdin.js

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: write EPIPE
at errnoException (net.js:642:11)
at Object.afterWrite [as oncomplete] (net.js:480:18)
```

If I replace stdin reading with direct

```javascript
s.run("1+1", function(output) {
console.log(output);
});
```

everything works fine.

How to deal with this?..