I have bash script that work for many files in loop. It compiles, check the result etc. Now I'd like to make a security in case of infinity loop inside of one of thouse files. something like: If it's not done after 5 min. Kill the process and gave info about that.
gcc -Wall -o "${FN}_execute" ${FN} 2> ${FN}_c_compilation.txt
./${FN}_execute $PARAM > ${FN}_c_result.txt
How to do that?
Take a look at:
http://www.bashcookbook.com/bashinfo/source/bash-4.0/examples/scripts/timeout3
You could record the start time (in seconds) and just check if the current time (in seconds) is more than 300.
But why are you writing a script to compile files manually? Doesn't make
do what you want?
精彩评论