ogle/program/server: clarify ordering of evaluation when ptraceRun
wraps a closure that 'returns' more than just an error.
I don't think this changes the actual behavior with the gc compiler,
but a different compiler might not optimize the "return foo" part
as a no-op, in:
func f() (foo int, err error) {
etc
return foo, <-s.ec
}
and then it's possibly racy whether foo is evaluated before or after
the channel receive.
LGTM=r
R=r
https://golang.org/cl/89750043
diff --git a/program/server/ptrace.go b/program/server/ptrace.go
index 9bd3357..989f154 100644
--- a/program/server/ptrace.go
+++ b/program/server/ptrace.go
@@ -30,7 +30,8 @@
proc, err1 = os.StartProcess(name, argv, attr)
return err1
}
- return proc, <-s.ec
+ err = <-s.ec
+ return
}
func (s *Server) ptraceCont(pid int, signal int) (err error) {
@@ -102,5 +103,6 @@
wpid, err1 = syscall.Wait4(pid, &status, syscall.WALL, nil)
return err1
}
- return wpid, status, <-s.ec
+ err = <-s.ec
+ return
}