1
0
mirror of https://github.com/google/gops.git synced 2024-11-27 08:31:17 +02:00

agent: check error return values (#109)

In func handle, check the error return values of pprof.WriteHeapProfile
and trace.Start.
This commit is contained in:
Tobias Klauser 2020-05-25 10:43:40 +02:00 committed by GitHub
parent 10df6abaad
commit ccffbf8d4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -228,7 +228,7 @@ func handle(conn io.ReadWriter, msg []byte) error {
case signal.Version:
fmt.Fprintf(conn, "%v\n", runtime.Version())
case signal.HeapProfile:
pprof.WriteHeapProfile(conn)
return pprof.WriteHeapProfile(conn)
case signal.CPUProfile:
if err := pprof.StartCPUProfile(conn); err != nil {
return err
@ -254,7 +254,9 @@ func handle(conn io.ReadWriter, msg []byte) error {
_, err = bufio.NewReader(f).WriteTo(conn)
return err
case signal.Trace:
trace.Start(conn)
if err := trace.Start(conn); err != nil {
return err
}
time.Sleep(5 * time.Second)
trace.Stop()
case signal.SetGCPercent: