Build steps hang on Windows if child processes still running
- Dominant language
- Go
- Stars
- 1.1k
- Forks
- 378
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 74
Description
I have the following script used in a Buildkite step (for reproduction purposes):
```bash
echo 1
sleep 60 &
echo 2
```
Note that `sleep 60 &` goes to the background, so this script exits immediately.
On linux, when running this script in a Buildkite step, the step finishes immediately (not after waiting 60s), as I would expect.
On Windows, however, the buildkite step hangs for 60 seconds, waiting for the child process to finish, even though the parent process completed.
It doesn't matter what shell is specified (I've tried powershell, pwsh, bash, and no shell (which defaults to cmd)), the behavior is always the same. The script exits immediately if run on Windows _outside_ of Buildkite. This all leads me to believe it's the Buildkite agent itself and how it manages processes.
Is this difference expected behavior? We have complex pipelines that spawn a lot of child processes (for example, a simple case is gradle daemons) and they hang indefinitely on Windows.
Is there a way around the behavior? I can't think of anything related to our environment that could cause this.
You can also run, for example, in batch:
`bash.exe -c 'echo 1; sleep 60 ^& echo 2;'`
Tested on: Windows 2022, 2019, 2016
buildkite-agent 3.48.0 and 3.49.0
Note that I e-mailed support, and they asked me to open an issue here.
Contributor guide
Assessment
This issue has not been assessed yet.