Skip to content

Commit 63f7764

Browse files
committed
Handle signal exits after walker close
Record whether the walker command returned after its context was canceled. Treat those wait errors as expected during Close so platforms that report cancellation as signal termination do not fail the unblock test.
1 parent 69c5a22 commit 63f7764

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

walk/path_stream.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ type PathStreamReader struct {
3737
eg *errgroup.Group
3838
scanner *bufio.Scanner
3939

40-
waitMu sync.Mutex
41-
waitErr error
40+
waitMu sync.Mutex
41+
waitErr error
42+
waitCanceled bool
4243
}
4344

4445
func (p *PathStreamReader) Read(ctx context.Context, files []*File) (n int, err error) {
@@ -153,7 +154,7 @@ func (p *PathStreamReader) Close() error {
153154
p.waitMu.Lock()
154155
defer p.waitMu.Unlock()
155156

156-
if p.waitErr != nil && !errors.Is(p.waitErr, context.Canceled) {
157+
if p.waitErr != nil && !errors.Is(p.waitErr, context.Canceled) && !p.waitCanceled {
157158
return fmt.Errorf("failed to wait for %s command to complete: %w", p.cfg.Name, p.waitErr)
158159
}
159160

@@ -252,6 +253,7 @@ func NewPathStreamReader(
252253

253254
reader.waitMu.Lock()
254255
reader.waitErr = err
256+
reader.waitCanceled = ctx.Err() != nil
255257
reader.waitMu.Unlock()
256258

257259
closeErr := stdoutW.Close()

0 commit comments

Comments
 (0)