diff options
| author | Alan Donovan <adonovan@google.com> | 2023-12-07 18:02:40 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-01-31 16:50:42 +0000 |
| commit | 1bb947b2eb62f54dd7ff621f7e1c768c00edd1a7 (patch) | |
| tree | 58f821389f1a025f8106b05856b942aa2fc4fa94 /src/runtime/write_err_android.go | |
| parent | 13766fe7d89c44bb45cfb33591b137553bda7c7d (diff) | |
| download | go-1bb947b2eb62f54dd7ff621f7e1c768c00edd1a7.tar.xz | |
runtime/debug: SetCrashOutput sets the FD for fatal panics
This feature makes it possible to record unhandled panics
in any goroutine through a watchdog process (e.g. the same
application forked+exec'd as a child in a special mode)
that can process the panic report, for example by sending
it to a crash-reporting system such as Go telemetry
or Sentry.
Fixes #42888
Change-Id: I5aa7be8f726bbc70fc650540bd1a14ab60c62ecb
Reviewed-on: https://go-review.googlesource.com/c/go/+/547978
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/write_err_android.go')
| -rw-r--r-- | src/runtime/write_err_android.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/runtime/write_err_android.go b/src/runtime/write_err_android.go index a876900c95..dd950774cb 100644 --- a/src/runtime/write_err_android.go +++ b/src/runtime/write_err_android.go @@ -34,6 +34,10 @@ const ( var logger loggerType func writeErr(b []byte) { + if len(b) == 0 { + return + } + if logger == unknown { // Use logd if /dev/socket/logdw is available. if v := uintptr(access(&writeLogd[0], 0x02 /* W_OK */)); v == 0 { @@ -45,8 +49,9 @@ func writeErr(b []byte) { } } - // Write to stderr for command-line programs. - write(2, unsafe.Pointer(&b[0]), int32(len(b))) + // Write to stderr for command-line programs, + // and optionally to SetCrashOutput file. + writeErrData(&b[0], int32(len(b))) // Log format: "<header>\x00<message m bytes>\x00" // |
