예제 #1
0
파일: exec.go 프로젝트: petemoore/runlib
func findSandbox(s []SandboxPair, request *contester_proto.LocalExecutionParameters) (*Sandbox, error) {
	if request.SandboxId != nil {
		return getSandboxById(s, request.GetSandboxId())
	}
	return getSandboxByPath(s, request.GetCurrentDirectory())
}
예제 #2
0
파일: exec.go 프로젝트: petemoore/runlib
func (s *Contester) setupSubprocess(request *contester_proto.LocalExecutionParameters, sandbox *Sandbox, doRedirects bool) (sub *subprocess.Subprocess, err error) {
	sub = subprocess.SubprocessCreate()

	sub.Cmd = &subprocess.CommandLine{
		ApplicationName: request.ApplicationName,
		CommandLine:     request.CommandLine,
		Parameters:      request.CommandLineParameters,
	}

	sub.CurrentDirectory = request.CurrentDirectory

	sub.TimeLimit = subprocess.DuFromMicros(request.GetTimeLimitMicros())
	sub.HardTimeLimit = subprocess.DuFromMicros(request.GetTimeLimitHardMicros())
	sub.MemoryLimit = request.GetMemoryLimit()
	sub.CheckIdleness = request.GetCheckIdleness()
	sub.RestrictUi = request.GetRestrictUi()
	sub.NoJob = request.GetNoJob()

	sub.Environment = fillEnv(request.Environment)

	if doRedirects {
		sub.StdIn = fillRedirect(request.StdIn)
		sub.StdOut = fillRedirect(request.StdOut)
	}

	if request.GetJoinStdoutStderr() {
		sub.JoinStdOutErr = true
	} else {
		sub.StdErr = fillRedirect(request.StdErr)
	}

	sub.Options = &subprocess.PlatformOptions{}

	if sandbox.Login != nil {
		sub.Login = sandbox.Login
	} else {
		if PLATFORM_ID == "linux" {
			sub.Login, err = subprocess.NewLoginInfo("compiler", "compiler")
			if err != nil {
				return
			}
		}
	}

	err = s.localPlatformSetup(sub, request)
	return
}