diff options
| author | Ian Lance Taylor <iant@golang.org> | 2016-01-25 09:54:39 -0800 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2016-01-25 20:55:44 +0000 |
| commit | 7688ffe1341a534d42367410f4a4bef0a31a7f37 (patch) | |
| tree | 4be74c49cbc0d74fb370cd73d072e58804c33c4d | |
| parent | cedbbfaa45fac82a0088b3163c7137e814020a53 (diff) | |
| download | go-7688ffe1341a534d42367410f4a4bef0a31a7f37.tar.xz | |
runtime/pprof: document SetCPUProfile with c-archive/c-shared
When using c-archive/c-shared, the signal handler for SIGPROF will not
be installed, which means that runtime/pprof.StartCPUProfile won't work.
There is no really good solution here, as the main program may want to
do its own profiling. For now, just document that runtime/pprof doesn't
work as expected, but that it will work if you use Notify to install the
Go signal handler.
Fixes #14043.
Change-Id: I7ff7a01df6ef7f63a7f050aac3674d640a246fb4
Reviewed-on: https://go-review.googlesource.com/18911
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
| -rw-r--r-- | src/runtime/pprof/pprof.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go index d32b31578d..7d677cb64e 100644 --- a/src/runtime/pprof/pprof.go +++ b/src/runtime/pprof/pprof.go @@ -567,6 +567,14 @@ var cpu struct { // StartCPUProfile enables CPU profiling for the current process. // While profiling, the profile will be buffered and written to w. // StartCPUProfile returns an error if profiling is already enabled. +// +// On Unix-like systems, StartCPUProfile does not work by default for +// Go code built with -buildmode=c-archive or -buildmode=c-shared. +// StartCPUProfile relies on the SIGPROF signal, but that signal will +// be delivered to the main program's SIGPROF signal handler (if any) +// not to the one used by Go. To make it work, call os/signal.Notify +// for syscall.SIGPROF, but note that doing so may break any profiling +// being done by the main program. func StartCPUProfile(w io.Writer) error { // The runtime routines allow a variable profiling rate, // but in practice operating systems cannot trigger signals |
