mirror of
https://github.com/criyle/go-judge.git
synced 2025-11-04 14:50:02 +08:00
29 lines
625 B
Go
29 lines
625 B
Go
package runner
|
|
|
|
import (
|
|
"github.com/criyle/go-judge/types"
|
|
"github.com/criyle/go-sandbox/deamon"
|
|
)
|
|
|
|
var env = []string{"PATH=/usr/local/bin:/usr/bin:/bin"}
|
|
|
|
func (r *runnerInstance) run(done <-chan struct{}, task *types.RunTask) *types.RunTaskResult {
|
|
var result types.RunTaskResult
|
|
|
|
waitDone := make(chan struct{})
|
|
param := r.Language.Get(task.Language, task.Type)
|
|
|
|
execParam := deamon.ExecveParam{
|
|
Args: param.Args,
|
|
Envv: env,
|
|
}
|
|
rc, err := r.Master1.Execve(waitDone, &execParam)
|
|
if err != nil {
|
|
result.Status = "JGF"
|
|
return &result
|
|
}
|
|
rt := <-rc
|
|
result.Status = rt.TraceStatus.Error()
|
|
return &result
|
|
}
|