1

This command is giving my unit tests trouble. The problem is that the test gets stuck waiting for the child process to receive a newline:

var cmd = spawn('ls');

So, I send a newline, as advised in this thread:

   setTimeout(function() {
        cmd.stdin.write('\n');
        console.log('Ending terminal session');
    }, 2000);

I get this exception:

Error: This socket has been ended by the other party
    at Socket.writeAfterFIN [as write] (net.js:275:12)

If I run the command from command line, as soon as I hit the enter key the function returns as expected, but it does not send the newline via stdin without the aforementioned error.

Community
  • 1
  • 1
Calvin Froedge
  • 16,135
  • 16
  • 55
  • 61
  • What are the values for `myscript` and `arg1` and `arg2`? – mscdex Oct 21 '14 at 05:37
  • String values, two file paths, and myscript is just a path to the ImageMagick executable in this case. – Calvin Froedge Oct 21 '14 at 05:46
  • What kind of interactive input is imagemagick requiring? I would think ordinarily something like image conversion would be a non-interactive task. – mscdex Oct 21 '14 at 05:50
  • @mscdex The point is that it doesn't matter what the process is. If it's `ls` it still freezes until I manually hit the return key. – Calvin Froedge Oct 21 '14 at 06:00

0 Answers0