bigjosh / NeoUart

Drive a WS2812B NeoPixel connected directly to a Raspberry Pi
25 stars 3 forks source link

Kill neouart process from Node.js #1

Open chatmurai opened 9 years ago

chatmurai commented 9 years ago

Hi,

First, thanks for this library ! I am experiencing issue when I try to kill a NeoUart process from Node.js.

colorsStr is a string containing 128 color values.

var exec = require('child_process').exec;
var ex = exec('neouart -i -q -s50 ' + colorsStr, {killSignal: 'SIGINT'},
function (error, stdout, stderr) {
    console.log( error, stdout, stderr );
});

setTimeout( function(){ex.kill('SIGINT');}, 3000);

The ex.kill('SIGKILL') does not kill process though it should.

bigjosh commented 9 years ago

Are you sending SIGINT or SIGKILL? It looks like the actual pasted code snip uses SIGINT, but maybe you meant SIGKILL there?

I don't trap SIGINT, but SIGKILL should always work - if not then it is an OS error!

LMK what you find.

-josh

chatmurai commented 9 years ago

Well I tried with SIGKILL too which is the default signal, but it did not work: the function is called, but the DEL goes on flashing but If I hit ctrl + c, the program exits, and the flashes stop.

bigjosh commented 9 years ago

I am not really a node.js guy, but maybe there is a race condition here?

How long does your color string take to run? If it is less than 3000ms, then the process might already be dead when the kill tries to kill it.

Maybe also do a console.log inside the timeout function and see when it is getting called?