Sunday 28 May 2017

Using node.js to spawn child process in windows sometimes doesn't clear buffer

In windows 10, I use node.js to create a child process, which I communicate to in a persistent way. I have listeners for exit and on data.

The problem is sometimes (very rarely), when I read data, some part of the beginning of the data, is part of what was there before as if a buffer was not cleared.

Sometimes the data gets split into chunks, and gets called multiple times.

Does anyone know how I can manually clear it?

Thanks

    var terminal = cp.spawn('cmd');

    terminal.stdout.on('data', function (data) {
         terminal.stdin.write('swipl code.pl\r\n');
    });

    terminal.on('exit', function (code) {

    });



via omega

No comments:

Post a Comment