module Mumukit::WithCommandLine

Constants

SIGINT
SIGSEGV
SIGXCPU

Public Instance Methods

command_size_limit() click to toggle source
# File lib/mumukit/with_command_line.rb, line 7
def command_size_limit
  Mumukit.config.command_size_limit
end
command_time_limit() click to toggle source
# File lib/mumukit/with_command_line.rb, line 11
def command_time_limit
  Mumukit.config.command_time_limit
end
limit_command() click to toggle source
# File lib/mumukit/with_command_line.rb, line 15
def limit_command
  Mumukit.config.limit_script
end
run_command(command) click to toggle source
# 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) click to toggle source
# 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