Skip to content

Commit

Permalink
Add timeout when compiling source code. Remove all box files before c…
Browse files Browse the repository at this point in the history
…leanup.
  • Loading branch information
hermanzdosilovic committed Feb 10, 2019
1 parent 72cff96 commit 2f05ce2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/jobs/isolate_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,21 @@ def write
def compile
return :success unless submission.language.compile_cmd

submission.compile_output = `cd #{box} && #{submission.language.compile_cmd} 2>&1`.presence
return :success if $?.success?
submission.compile_output = `cd #{box} && timeout -s 15 -k 5s 10s #{submission.language.compile_cmd} 2>&1`.presence

process_status = $?
return :success if process_status.success?

if [124, 137].include? process_status.exitstatus
submission.compile_output = "Compilation time limit exceeded."
end

submission.update(
status: Status.ce,
finished_at: DateTime.now
)
:failure

return :failure
end

def run
Expand Down Expand Up @@ -118,6 +125,7 @@ def verify
end

def clean
`rm #{box}/*`
`isolate #{cgroups} -b #{id} --cleanup`
end

Expand Down

0 comments on commit 2f05ce2

Please sign in to comment.