main: get rid of third open paniclog fd

We have it saved in Stderr and Stdout anyway, let's free this fd
number.
This commit is contained in:
Jakob Unterwurzacher 2017-02-26 22:43:36 +01:00
parent c304626a47
commit b765cc526d
2 changed files with 4 additions and 1 deletions

Binary file not shown.

View File

@ -134,6 +134,8 @@ func doMount(args *argContainer) int {
// https://github.com/golang/go/issues/325#issuecomment-66049178 // https://github.com/golang/go/issues/325#issuecomment-66049178
syscall.Dup2(int(paniclog.Fd()), 1) syscall.Dup2(int(paniclog.Fd()), 1)
syscall.Dup2(int(paniclog.Fd()), 2) syscall.Dup2(int(paniclog.Fd()), 2)
// No need for the extra FD anymore, we have it saved in Stderr
paniclog.Close()
} }
// Disconnect from the controlling terminal by creating a new session. // Disconnect from the controlling terminal by creating a new session.
// This prevents us from getting SIGINT when the user presses Ctrl-C // This prevents us from getting SIGINT when the user presses Ctrl-C
@ -153,7 +155,8 @@ func doMount(args *argContainer) int {
srv.Serve() srv.Serve()
// Delete empty paniclogs // Delete empty paniclogs
if paniclog != nil { if paniclog != nil {
fi, err := paniclog.Stat() // The paniclog FD is saved in Stderr
fi, err := os.Stderr.Stat()
if err != nil { if err != nil {
tlog.Warn.Printf("paniclog fstat error: %v", err) tlog.Warn.Printf("paniclog fstat error: %v", err)
} else if fi.Size() > 0 { } else if fi.Size() > 0 {