Module: Mumukit::WithCommandLine
- Defined in:
- lib/mumukit/with_command_line.rb
Constant Summary collapse
- SIGINT =
2
- SIGSEGV =
11
- SIGXCPU =
24
Instance Method Summary collapse
- #command_size_limit ⇒ Object
- #command_time_limit ⇒ Object
- #limit_command ⇒ Object
- #run_command(command) ⇒ Object
- #signal_status(signal) ⇒ Object
Instance Method Details
#command_size_limit ⇒ Object
7 8 9 |
# File 'lib/mumukit/with_command_line.rb', line 7 def command_size_limit Mumukit.config.command_size_limit end |
#command_time_limit ⇒ Object
11 12 13 |
# File 'lib/mumukit/with_command_line.rb', line 11 def command_time_limit Mumukit.config.command_time_limit end |
#limit_command ⇒ Object
15 16 17 |
# File 'lib/mumukit/with_command_line.rb', line 15 def limit_command Mumukit.config.limit_script end |
#run_command(command) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mumukit/with_command_line.rb', line 19 def run_command(command) out = %x{#{limit_command} #{command_size_limit} #{command_time_limit} $(cat <<EOLIMIT #{command} EOLIMIT )} case $?.exitstatus when 0 then [out, :passed] when signal_status(SIGINT) then [I18n.t('mumukit.memory_exceeded'), :aborted] when signal_status(SIGSEGV) then [I18n.t('mumukit.memory_exceeded'), :aborted] when signal_status(SIGXCPU) then [I18n.t('mumukit.time_exceeded', limit: command_time_limit), :aborted] else [out, :failed] end end |
#signal_status(signal) ⇒ Object
33 34 35 36 |
# File 'lib/mumukit/with_command_line.rb', line 33 def signal_status(signal) # see http://tldp.org/LDP/abs/html/exitcodes.html 128 + signal end |