Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

ShellCommandsAndWait: don't wait for children processes #179

Merged
merged 6 commits into from
Sep 13, 2021

Conversation

edigaryev
Copy link
Contributor

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).

@edigaryev edigaryev requested a review from fkorotkov September 12, 2021 17:58
@edigaryev edigaryev force-pushed the dont-wait-for-children branch from 93ec572 to a061dda Compare September 12, 2021 18:31
if runtime.GOOS == "windows" {
result = piper.r.Close()
} else {
result = piper.r.SetReadDeadline(time.Now().Add(time.Millisecond * 100))
Copy link
Contributor

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?

Copy link
Contributor Author

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.

}

func (piper *Piper) Close() (result error) {
// Cancel the Goroutine started in New(): ungracefully Windows and gracefully for other platforms
Copy link
Contributor

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

Copy link
Contributor Author

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.

@edigaryev edigaryev requested a review from fkorotkov September 13, 2021 10:35
@edigaryev edigaryev enabled auto-merge (squash) September 13, 2021 10:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FreeBSD job doesn't finish sometimes even if all tasks finished and succeded.
2 participants