# HG changeset patch # User Nattee Niparnan # Date 2014-08-19 18:58:25 # Node ID 19e4c7e30be4ec3a73ed20d1f1942f3cf8d0b035 # Parent b4e13c98cfec1a9e54743de0208de2ae1dc44a35 fix java compiler and runner box does not stop on time because we let box run the script, not the java itself diff --git a/std-script/compile b/std-script/compile --- a/std-script/compile +++ b/std-script/compile @@ -116,8 +116,10 @@ command = "#{JAVA_COMPILER} #{classname}.java 2> #{params[:message_file]}" system(command) if File.exists?(classname + ".class") - File.open(params[:output_file],"w") {|file| file.write("#!/bin/sh\n/usr/bin/java #{classname}\n")} - File.chmod(0755, params[:output_file]) + File.open(params[:output_file],"w") {|file| file.write("#{classname}")} + end + if classname == 'DUMMY' + File.open(params[:message_file],"w") {|file| file.write("Cannot find any public class in the source code\n")} end when "ruby" diff --git a/std-script/run b/std-script/run --- a/std-script/run +++ b/std-script/run @@ -91,8 +91,14 @@ case language when "java" - # for java, we have to add additional systemcall and we don't check the mem limit (dunno how to fix...) - run_command = "#{problem_home}/script/box -T -t #{time_limit} -s getppid -s clone -s wait4 -p /usr/bin/ -p ./ -i #{input_file_name} -o output.txt #{program_name} 2>run_result" + + # for java, extract the classname + # wne have to add additional systemcall and we don't check the mem limit (dunno how to fix...) + classname = 'DUMMY' + File.open(program_name,"r").each do |line| + classname = line + end + run_command = "#{problem_home}/script/box -T -t #{time_limit} -s getppid -s clone -s wait4 -p /usr/bin/ -p ./ -i #{input_file_name} -o output.txt /usr/bin/java #{classname} 2>run_result" when "ruby" run_command = "#{problem_home}/script/box -T -t #{time_limit} -s getppid -s wait4 -s clone -s set_robust_list -s futex -s sigaltstack -p /dev/urandom -p ./ -p /home/dae/.rvm/rubies/ruby-1.9.2-p320/ -p #{problem_home}/ -i #{input_file_name} -o output.txt #{program_name} 2>run_result" when "python"