-
Notifications
You must be signed in to change notification settings - Fork 6
ShellCommandsAndWait: don't wait for children processes #179
Conversation
93ec572
to
a061dda
Compare
internal/executor/piper/piper.go
Outdated
if runtime.GOOS == "windows" { | ||
result = piper.r.Close() | ||
} else { | ||
result = piper.r.SetReadDeadline(time.Now().Add(time.Millisecond * 100)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to sleep here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can just Close()
our end of the pipe, since the process we started has already been Wait()
'ed for.
See 0043282.
internal/executor/piper/piper.go
Outdated
} | ||
|
||
func (piper *Piper) Close() (result error) { | ||
// Cancel the Goroutine started in New(): ungracefully Windows and gracefully for other platforms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe separate the logic into two smaller method like closeGracefully
and closeUngracefully
? I think it will be easier to follow the logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See 0043282 for a more straightforward logic.
Resolves cirruslabs/cirrus-ci-docs#910 by working around golang/go#23019.
This issue was first spotted in #23, however, the PR that fixed it only targets cases where the shell is terminated by a timeout and not cases where the shell has exited cleanly (yet left behind the descendants that referenced it's stderr/stdout file descriptors).