// runSingle runs Cmd inside the given environment and cgroup
runSingle runs Cmd inside the given environment and cgroup
// runSingle runs Cmd inside the given environment and cgroup
func runSingle(pc context.Context, c *Cmd, fds []*os.File, ptc []pipeCollector, newStoreFile NewStoreFile) (result Result, err error) {
	m := c.Environment
	if fe, err := runSingleCopyIn(m, c.CopyIn); err != nil {
		result.Status = StatusFileError
		result.Error = err.Error()
		result.FileError = fe
		closeFiles(fds...)
		return result, nil
	}
	rt := runSingleWait(pc, m, c, fds)
	files, fe, err := copyOutAndCollect(m, c, ptc, newStoreFile)
	result = Result{
		Status:     convertStatus(rt.Status),
		ExitStatus: rt.ExitStatus,
		Error:      rt.Error,
		Time:       rt.Time,
		RunTime:    rt.RunningTime,
		Memory:     rt.Memory,
		Files:      files,
		FileError:  fe,
	}
	if rt.Status == runner.StatusNormal && err != nil && result.Error == "" {
		switch err := err.(type) {
		case runner.Status:
			result.Status = convertStatus(err)
		default:
			result.Status = StatusFileError
		}
		result.Error = err.Error()
	}
	if result.Time > c.TimeLimit {
		result.Status = StatusTimeLimitExceeded
	}
	if result.Memory > c.MemoryLimit {
		result.Status = StatusMemoryLimitExceeded
	}
	return result, nil
}
func runSingle ( pc context . Context , c * Cmd , fds [ ] * os . File , ptc [ ] pipeCollector , newStoreFile NewStoreFile ) ( result Result , err error ) { m := c . Environment if fe , err := runSingleCopyIn ( m , c . CopyIn ) ; err != nil { result . Status = StatusFileError result . Error = err . Error ( ) result . FileError = fe closeFiles ( fds ... ) return result , nil } rt := runSingleWait ( pc , m , c , fds ) files , fe , err := copyOutAndCollect ( m , c , ptc , newStoreFile ) result = Result { Status : convertStatus ( rt . Status ) , ExitStatus : rt . ExitStatus , Error : rt . Error , Time : rt . Time , RunTime : rt . RunningTime , Memory : rt . Memory , Files : files , FileError : fe , } if rt . Status == runner . StatusNormal && err != nil && result . Error == " " { switch err := err . ( type ) { case runner . Status : result . Status = convertStatus ( err ) default : result . Status = StatusFileError } result . Error = err . Error ( ) } if result . Time > c . TimeLimit { result . Status = StatusTimeLimitExceeded } if result . Memory > c . MemoryLimit { result . Status = StatusMemoryLimitExceeded } return result , nil }
runSingle runs Cmd inside the given environment and cgroup
runSingle runs Cmd inside the given environment and cgroup
// copyin // run cmd and wait for result // collect result // collect error (only if the process exits normally)