Ich habe eine einfache node.js App, um Stdin zu echo. Wenn ich es interaktiv auf der Windows-Konsole ausführte, erwartete ich, dass Control-Z als EOF-Signal erkannt wurde. Aber es ist nicht. Wie bekomme ich eine Knoten-App, um Control-Z als EOF zu behandeln?Wie signalisieren Sie EOF zu node.js stdin von der Konsole?
// testEcho.js
process.stdin.setEncoding('utf-8');
console.log("input is a TTY?:",process.stdin.isTTY);
process.stdin.on('readable',function() {
var vText = process.stdin.read();
if (vText != null)
console.log('echo: "%s"',vText);
process.stdout.write('> '); // prompt for next
});
process.stdin.on('end',function() { // Works for redirected input but not triggered by ^Z on TTY
console.log('end of input reached');
});
`` `
'process.on („SIGINT“, fn);' – naomik