@@ -64,9 +64,6 @@ const (
6464 abrt traceout = "crash" // GOOS-specific crash after tracing
6565)
6666
67- // auto-capture recent logs in crash output?
68- const crashoutWithHist = false
69-
7067func (t traceout ) s () string { return string (t ) }
7168
7269const minMemLimit = 32 * 1024 * 1024 // 32MiB
@@ -432,56 +429,15 @@ func setCrashFd(f *os.File) (ok bool) {
432429// Returns true if successful, false on error (the file cannot be opened).
433430func SetCrashOutput (fp string ) bool {
434431 return sync .OnceValue (func () (ok bool ) {
435- if crashoutWithHist {
436- ok = setCrashOutput (fp )
437- } else {
438- fout , err := os .OpenFile (filepath .Clean (fp ), os .O_APPEND | os .O_WRONLY | os .O_CREATE , 0600 )
439- if err == nil {
440- ok = setCrashFd (fout )
441- }
442- logei (err )("tun: crashout: open %s; err? %v" , fp , err )
443- return ok
432+ fout , err := os .OpenFile (filepath .Clean (fp ), os .O_APPEND | os .O_WRONLY | os .O_CREATE , 0600 )
433+ if err == nil {
434+ ok = setCrashFd (fout )
444435 }
445- log . I ( "tun: crashout: set %s, hist? false; ok ? %t " , fp , ok )
436+ logei ( err )( "tun: crashout: open %s; err ? %v " , fp , err )
446437 return ok
447438 })()
448439}
449440
450- func setCrashOutput (fp string ) bool {
451- fout , err := os .OpenFile (filepath .Clean (fp ), os .O_APPEND | os .O_WRONLY | os .O_CREATE , 0600 )
452- if err != nil {
453- logei (err )("tun: crashout: open %s; err? %v" , fp , err )
454- return false
455- }
456-
457- r , w , err := os .Pipe ()
458- if err != nil {
459- core .CloseFile (fout )
460- logei (err )("tun: crashout: pipe %s; err? %v" , fp , err )
461- return false
462- }
463-
464- if ! setCrashFd (w ) { // pw is dup'd
465- core .Close (fout , r , w )
466- return false
467- }
468- core .Close (w ) // runtime holds its own dup; safe to close our end
469-
470- // goroutine: block on pr, then drain crash output + ring buffer into fout
471- core .Go ("crashout." + fname (fout ), func () {
472- defer core .Close (fout , r )
473-
474- n , _ := core .Stream (fout , r ) // blocks until crash output arrives
475- if n > 0 { // append the recent history
476- log .Hist (fout )
477- }
478- runtime .KeepAlive (fout )
479- runtime .KeepAlive (r )
480- })
481-
482- return true
483- }
484-
485441// SetFlightRecordOutput opens a writable file (and keeps it open) for Go's flight recorder
486442// to write to (on panics, for example). The flight recorder must be enabled via FlightRecorder(true)
487443// for this to be functional. Returns previous file name, if any. May error if fp cannot be opened.
0 commit comments