mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-10-31 12:28:20 +08:00
test: fix race in TestTreeKillCancelBeforeCaptureKillsTree (#1360)
`TestTreeKillCancelBeforeCaptureKillsTree` fails intermittently on CI, e.g. https://gitea.com/gitea/runner/actions/runs/1155856. Dash, the Ubuntu `/bin/sh`, points a background job's stdin at `/dev/null` before applying its redirections, so `cat <&0 &` read EOF and exited at once and the liveness check raced it. The pipe is now handed over on fd 3, which dash leaves alone. Introduced in https://gitea.com/gitea/runner/pulls/1338 Reviewed-on: https://gitea.com/gitea/runner/pulls/1360 Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
This commit is contained in:
@@ -104,7 +104,7 @@ func TestTreeKillCancelBeforeCaptureKillsTree(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { _ = stdin.Close() })
|
||||
t.Cleanup(func() { _ = input.Close() })
|
||||
cmd := exec.CommandContext(t.Context(), "/bin/sh", "-c", "cat <&0 & echo $!; read value")
|
||||
cmd := exec.CommandContext(t.Context(), "/bin/sh", "-c", "exec 3<&0; cat <&3 & echo $!; read value")
|
||||
cmd.Stdin = stdin
|
||||
cmd.SysProcAttr = SysProcAttr("", false)
|
||||
output, err := cmd.StdoutPipe()
|
||||
|
||||
Reference in New Issue
Block a user