os: use runtime.Keepalive for *Process values
The os package sets a finalizer on *Process. I looked through all the uses of *Process in the package, looking for each case where a *Process was passed as an argument and the final reference to the argument was not a function or method call. I added a call to runtime.KeepAlive after each such final reference (there were only three). The code is safe today without the KeepAlive calls because the compiler keeps arguments alive for the duration of the function. However, that is not a language requirement, so adding the KeepAlive calls ensures that this code remains safe even if the compiler changes in the future. I also removed an existing unnecessry call to runtime.KeepAlive. The syscall.Syscall function is handled specially by the compiler to keep its arguments alive. Change-Id: Ibd2ff20b31ed3de4f6a59dd1633c1b44001d91d9 Reviewed-on: https://go-review.googlesource.com/27637 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Showing
Please register or sign in to comment