hprasath commited on
Commit
5502f95
1 Parent(s): b0ad755

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +2 -1
index.js CHANGED
@@ -79,10 +79,11 @@ app.post("/compile", function (req, res) {
79
  }
80
  const cppProcess = exec(
81
  "g++ -o /code/temp/Main /code/temp/Main.cpp && /code/temp/Main",
 
82
  (error, stdout, stderr) => {
83
  if (error) {
84
  console.error(error);
85
- res.send({ error: stderr });
86
  return;
87
  }
88
  console.error(stderr);
 
79
  }
80
  const cppProcess = exec(
81
  "g++ -o /code/temp/Main /code/temp/Main.cpp && /code/temp/Main",
82
+ { timeout: TIMEOUT_VALUE }, // Add timeout option
83
  (error, stdout, stderr) => {
84
  if (error) {
85
  console.error(error);
86
+ res.send({ error: "Compilation or execution timed out" });
87
  return;
88
  }
89
  console.error(stderr);