Slide 68
Slide 68 text
NPDLϓϩηεͷঢ়ଶมԽΛࢹ
processExitChannel chan int
func (t *Tower) mockExec(mock MockCode, version string, ...) {
// ىಈઃఆϑΝΠϧͷऔಘͱ͔(ུ)
// ϓϩηεىಈ
var proc *os.Process
proc, err = os.StartProcess(binPath, args, attr)
// PidΛอଘ
mockProcessTable[proc.Pid] = mock
// goroutineͰऴྃࢹ
go func(t *Tower, mock MockCode, pid int) {
for {
var status syscall.WaitStatus
var rusage syscall.Rusage
wpid, err := syscall.Wait4(pid, &status, syscall.WNOHANG, &rusage)
if err != nil || (wpid != 0 && status.Exited()) {
processExitChannel <- pid
return
}
time.Sleep(intervalMsec)
}
}(t, mock, proc.Pid)