Skip to content

Commit

Permalink
interp: work around apparent Go 1.24 regression with os.DevNull on Wi…
Browse files Browse the repository at this point in the history
…ndows

This should fix the Windows errors on CI affecting Go 1.24.
  • Loading branch information
mvdan committed Feb 14, 2025
1 parent 0115260 commit 6c76d27
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions interp/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ func DefaultOpenHandler() OpenHandlerFunc {
if path != "" && !filepath.IsAbs(path) {
path = filepath.Join(mc.Dir, path)
}
// Work around https://go.dev/issue/71752, where Go 1.24 started giving
// "Invalid handle" errors when opening "NUL" with O_TRUNC.
// TODO: hopefully remove this in the future once the bug is fixed.
if path == os.DevNull {
flag &^= os.O_TRUNC
}
return os.OpenFile(path, flag, perm)
}
}
Expand Down

0 comments on commit 6c76d27

Please sign in to comment.