Skip to content
Permalink
Browse files

pkg/ipc: clarify why we close inwp explicitly

Fixes #897
  • Loading branch information...
dvyukov committed Dec 27, 2018
1 parent e747ec9 commit 8e3d1cba5a65fa18428385ee1549b9fd3c46892d
Showing with 5 additions and 1 deletion.
  1. +5 −1 pkg/ipc/ipc.go
@@ -589,6 +589,9 @@ func makeCommand(pid int, bin []string, config *Config, inFile, outFile *os.File
}
c.cmd = cmd
wp.Close()
// Note: we explicitly close inwp before calling handshake even though we defer it above.
// If we don't do it and executor exits before writing handshake reply,
// reading from inrp will hang since we hold another end of the pipe open.
inwp.Close()

if c.config.Flags&FlagUseForkServer != 0 {
@@ -615,7 +618,7 @@ func (c *command) close() {
}
}

// handshake sends handshakeReq and waits for handshakeReply (sandbox setup can take significant time).
// handshake sends handshakeReq and waits for handshakeReply.
func (c *command) handshake() error {
req := &handshakeReq{
magic: inMagic,
@@ -641,6 +644,7 @@ func (c *command) handshake() error {
}
read <- nil
}()
// Sandbox setup can take significant time.
timeout := time.NewTimer(time.Minute)
select {
case err := <-read:

0 comments on commit 8e3d1cb

Please sign in to comment.
You can’t perform that action at this time.