i'm trying to make and c REPL, so I need to interact with the stdin how many times as the c code needs. Currently a have this code (Just one time)
const spawn = require('child_process').spawn;
const gcc = spawn('gcc', ['-Wall', 'main.c', '-o', 'main', '-lm']);
gcc.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
gcc.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
gcc.on('close', (code) => {
console.log(`child process exited with code ${code}`);
const child = spawn('./main')
child.stdin.setEncoding('utf-8');
child.stdout.pipe(process.stdout)
child.stdin.write("5\n");
child.stdin.end();
});
Any clues?
via Yhozen
No comments:
Post a Comment