I use the following to compile my C++ Program.
g++ filename.cpp -o filename.o
Then I take an input file and direct the output to the another file.
filename.o < in.txt > out.txt
However sometimes the code goes into an infinite loop and I am not able to stop it (I force quit the .o
from Activity Monitor).
What is want it to put an execution limit time on the program so that after it it automatically stops executing. Is there any way to this?
Something like:- g++ filename.cpp -o filename.o [execution_limit_here=10.0s]
Edit:- I am creating an Atom Package and users will compile and execute their code for a particular set of input files, using a simple key combination.
So I can’t predict beforehand if the code will go into an infinite loop.