I\'m writing a mock-grading script in bash. It\'s supposed to execute a C program which will give some output (which I redirect to a file.) I\'m trying to (1) make it timeout af
you can use timeout command eg
timeout
timeout -s 9 5s ./c_program > file
to check file size, you can stat the file, then do if/else
if/else
limit=1234 #bytes size=$(stat -c "%s" file) if [ "$size" -gt "$limit" ] ;then exit fi
see also here if you can't use these GNU tools, or here for some other inspirations.