1
0
mirror of https://github.com/golang/go synced 2024-11-23 06:40:05 -07:00

os/exec: use "pfiles" for fd debugging on illumos

On illumos (and Solaris) systems, the native "pfiles" tool provides the
best information about open file descriptors for a process:

    https://illumos.org/man/1/pfiles

Use that instead of "lsof" when debugging file descriptor leaks.

Updates #42431.

Change-Id: If1250c4e6c9e8adbd076495a09fb1ce63abcc68b
Reviewed-on: https://go-review.googlesource.com/c/go/+/268019
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Joshua M. Clulow 2020-11-06 13:11:58 -08:00 committed by Ian Lance Taylor
parent a6755fc0de
commit bb9a96d03a

View File

@ -56,7 +56,7 @@ func main() {
switch runtime.GOOS { switch runtime.GOOS {
case "plan9": case "plan9":
args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())} args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())}
case "aix": case "aix", "solaris", "illumos":
args = []string{fmt.Sprint(os.Getpid())} args = []string{fmt.Sprint(os.Getpid())}
default: default:
args = []string{"-p", fmt.Sprint(os.Getpid())} args = []string{"-p", fmt.Sprint(os.Getpid())}
@ -71,6 +71,8 @@ func main() {
ofcmd = "/bin/cat" ofcmd = "/bin/cat"
case "aix": case "aix":
ofcmd = "procfiles" ofcmd = "procfiles"
case "solaris", "illumos":
ofcmd = "pfiles"
} }
cmd := exec.Command(ofcmd, args...) cmd := exec.Command(ofcmd, args...)