MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / getProcessOptions

Function getProcessOptions

executor/runtime.go:274–357  ·  view source on GitHub ↗

运行一个新的进程

(session *JudgeSession, rst *commonStructs.TestCaseResult, isChecker, pipeMode bool, pipeFd []uintptr)

Source from the content-addressed store, hash-verified

272
273// 运行一个新的进程
274func getProcessOptions(session *JudgeSession, rst *commonStructs.TestCaseResult, isChecker, pipeMode bool, pipeFd []uintptr) (*PArgs, error) {
275 var err error
276 // Get shell commands
277 commands := session.Commands
278 // 参考exec.Command,从环境变量获取编译器/VM真实的地址
279 programPath := commands[0]
280 if filepath.Base(programPath) == programPath {
281 if programPath, err = exec.LookPath(programPath); err != nil {
282 return nil, err
283 }
284 }
285 var infile, outfile, errfile string
286 var rlimit forkexec.ExecRLimit
287 var args []string
288 var files []interface{}
289 var execProgram string
290 infile = path.Join(session.ConfigDir, rst.Input)
291 if isChecker {
292 execProgram = session.JudgeConfig.SpecialJudge.Checker
293 // 如果不使用TestLib,可以开启把程序的Answer发送到Checker的Stdin,兼容以前的判题程序用。
294 if !session.JudgeConfig.SpecialJudge.UseTestlib {
295 if session.JudgeConfig.SpecialJudge.RedirectProgramOut {
296 infile = path.Join(session.SessionDir, rst.ProgramOut)
297 }
298 }
299 outfile = path.Join(session.SessionDir, rst.CheckerOut)
300 errfile = path.Join(session.SessionDir, rst.CheckerError)
301 rlimit = forkexec.ExecRLimit{
302 TimeLimit: session.JudgeConfig.SpecialJudge.TimeLimit,
303 MemoryLimit: session.JudgeConfig.SpecialJudge.MemoryLimit,
304 RealTimeLimit: session.JudgeConfig.RealTimeLimit,
305 FileSizeLimit: session.JudgeConfig.FileSizeLimit,
306 }
307 args = getSpecialJudgeArgs(session, rst)
308 } else {
309 execProgram = programPath
310 outfile = path.Join(session.SessionDir, rst.ProgramOut)
311 errfile = path.Join(session.SessionDir, rst.ProgramError)
312 rlimit = forkexec.ExecRLimit{
313 TimeLimit: session.JudgeConfig.TimeLimit,
314 MemoryLimit: session.JudgeConfig.MemoryLimit,
315 RealTimeLimit: session.JudgeConfig.RealTimeLimit,
316 FileSizeLimit: session.JudgeConfig.FileSizeLimit,
317 }
318 args = commands
319 }
320 if pipeMode {
321 // Open err file
322 stderr, err := os.OpenFile(errfile, os.O_WRONLY|os.O_CREATE, 0644)
323 if err != nil {
324 return nil, err
325 }
326 files = []interface{}{pipeFd[0], pipeFd[1], stderr}
327 } else {
328 // Open in file
329 stdin, err := os.OpenFile(infile, os.O_RDONLY, 0)
330 if err != nil {
331 return nil, err

Callers 2

runAsyncFunction · 0.85
runInteractiveAsyncFunction · 0.85

Calls 1

getSpecialJudgeArgsFunction · 0.85

Tested by

no test coverage detected