I am making an online ide using node.js and child processes to interact with the terminal. But I am not able to handle the case where the client submits a code with dead end for eg a code likewhile(true);.
How should I terminate the process from the memory ram from within the node.js which takes too much time? Do I need to use to process.kill() Here is my code
return new Promise((resolve, reject) => {
var output;
var child=()=>exec(
`g++ ${filepath} -o ${outPath} && cd ${outputPath} && .\\${jobId}.exe`,//double back slash to prevent escaping of backticks or dollar sign
(error, stdout, stderr) => {
error && reject({ error, stderr });
stderr && reject(stderr);
resolve(stdout);
}
);