-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
What version of Go are you using (go version
)?
$ go version go version go1.12.4 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go envGOARCH="amd64"
GOBIN=""
GOCACHE="/home/si9ma/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/si9ma/Go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build113116426=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I use follow code to get ru_maxrss
data:
package main
import (
"fmt"
"os/exec"
"syscall"
)
func main() {
cmd := exec.Command("/usr/bin/ls")
if err := cmd.Run(); err != nil {
fmt.Println("error", err)
}
ru := cmd.ProcessState.SysUsage().(*syscall.Rusage)
fmt.Println(ru.Maxrss)
}
the result is 1960
However, if I import some other package,eg:
package main
import (
"fmt"
"os/exec"
"syscall"
_ "github.com/gin-gonic/gin"
_ "github.com/go-redis/redis"
_ "github.com/go-sql-driver/mysql"
)
func main() {
cmd := exec.Command("/usr/bin/ls")
if err := cmd.Run(); err != nil {
fmt.Println("error", err)
}
ru := cmd.ProcessState.SysUsage().(*syscall.Rusage)
fmt.Println(ru.Maxrss)
}
I will get the result 8928
What did you expect to see?
I just want to get the rusage
data of child process
What did you see instead?
It seems that child process inherit the rusage
data of parent process.