File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,11 @@ func startInitialization() (retErr error) {
107107
108108 defer func () {
109109 // If this defer is ever called, this means initialization has failed.
110- // Send the error back to the parent process in the form of an initError.
110+ // Send the error back to the parent process in the form of an initError
111+ // if the sync socket has not been closed.
112+ if syncPipe .isClosed () {
113+ return
114+ }
111115 ierr := initError {Message : retErr .Error ()}
112116 if err := writeSyncArg (syncPipe , procError , ierr ); err != nil {
113117 fmt .Fprintln (os .Stderr , err )
Original file line number Diff line number Diff line change 44 "fmt"
55 "io"
66 "os"
7+ "sync/atomic"
78
89 "golang.org/x/sys/unix"
910)
@@ -14,7 +15,8 @@ import (
1415// which ends up making things like json.Decoder hang forever if the packet is
1516// bigger than the internal read buffer.
1617type syncSocket struct {
17- f * os.File
18+ f * os.File
19+ closed atomic.Bool
1820}
1921
2022func newSyncSocket (f * os.File ) * syncSocket {
@@ -26,9 +28,15 @@ func (s *syncSocket) File() *os.File {
2628}
2729
2830func (s * syncSocket ) Close () error {
31+ // Even with errors from Close(), we have to assume the pipe was closed.
32+ s .closed .Store (true )
2933 return s .f .Close ()
3034}
3135
36+ func (s * syncSocket ) isClosed () bool {
37+ return s .closed .Load ()
38+ }
39+
3240func (s * syncSocket ) WritePacket (b []byte ) (int , error ) {
3341 return s .f .Write (b )
3442}
You can’t perform that action at this time.
0 commit comments