linux - Node spawn stdout.on data delay -


i checking usb drive removal on linux. monitoring output of command line process child_process.spawn. reason child's stdout data event doesn't emit until 20 lines have been printed, makes unable detect removed drive. after removing drive many times, go. won't do.

original:

var udevmonitor = require("child_process").spawn("udevadm", ["monitor", "--udev"]);  udevmonitor.stdout.on("data", function(data) {    return console.log(data.tostring());  });

pretty simple. figure it's issue piping node using internally. instead of using pipe, figure i'll use simple passthrough stream. solve problem , give me real-time output. code is:

var stdout = new require('stream').passthrough();  require("child_process").spawn("udevadm", ["monitor", "--udev"], { stdio: ['pipe', stdout, 'pipe'] });    stdout.on("data", function(data) {    console.log(data.tostring());  });

but gives me error: child_process.js:922 throw new typeerror('incorrect value stdio stream: ' + stdio);

the documentation says can pass stream in. don't see i'm doing wrong , stepping through child_process source didn't help.

can help? can run yourself, provided you're on linux. run code , insert usb drive. perhaps can run command 'udevadm monitor --udev' in terminal see happens. remove , reinsert few times , node print out.

mscdex, love you. changing spawn command

spawn("stdbuf", ["-ol", "-el", "udevadm", "monitor", "--udev"]);

did trick. appreciate help!


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -