Skip to content

Commit a8552c7

Browse files
runtime/debug: add the options parameter to SetCrashOutput
1 parent 619b419 commit a8552c7

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/runtime/debug/example_monitor_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func monitor() {
9191
if err != nil {
9292
log.Fatalf("StdinPipe: %v", err)
9393
}
94-
debug.SetCrashOutput(pipe.(*os.File)) // (this conversion is safe)
94+
debug.SetCrashOutput(pipe.(*os.File), debug.CrashOptions{}) // (this conversion is safe)
9595
if err := cmd.Start(); err != nil {
9696
log.Fatalf("can't start monitor: %v", err)
9797
}

src/runtime/debug/stack.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ func Stack() []byte {
3131
}
3232
}
3333

34+
// CrashOptions is a placeholder type for future options to SetCrashOutput.
35+
type CrashOptions struct{}
36+
3437
// SetCrashOutput configures a single additional file where unhandled
3538
// panics and other fatal errors are printed, in addition to standard error.
3639
// There is only one additional file: calling SetCrashOutput again overrides
@@ -40,7 +43,7 @@ func Stack() []byte {
4043
// To disable this additional crash output, call SetCrashOutput(nil).
4144
// If called concurrently with a crash, some in-progress output may be written
4245
// to the old file even after an overriding SetCrashOutput returns.
43-
func SetCrashOutput(f *os.File) error {
46+
func SetCrashOutput(f *os.File, opts CrashOptions) error {
4447
fd := ^uintptr(0)
4548
if f != nil {
4649
// The runtime will write to this file descriptor from

src/runtime/debug/stack_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestMain(m *testing.M) {
2929
if err != nil {
3030
log.Fatal(err)
3131
}
32-
if err := SetCrashOutput(f); err != nil {
32+
if err := SetCrashOutput(f, CrashOptions{}); err != nil {
3333
log.Fatal(err) // e.g. EMFILE
3434
}
3535
println("hello")

src/runtime/traceback_system_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func crash() {
2828
// Ensure that we get pc=0x%x values in the traceback.
2929
debug.SetTraceback("system")
3030
writeSentinel(os.Stdout)
31-
debug.SetCrashOutput(os.Stdout)
31+
debug.SetCrashOutput(os.Stdout, debug.CrashOptions{})
3232

3333
go func() {
3434
// This call is typically inlined.

0 commit comments

Comments
 (0)