Skip to content

Commit

Permalink
runtime/testdata/testprog: close files in the tidExists GCFairness func
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
  • Loading branch information
testwill committed Apr 19, 2024
1 parent 334ce51 commit 84b1182
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/runtime/testdata/testprog/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func GCFairness() {
fmt.Println("OK")
return
}
defer f.Close()

if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/testdata/testprog/syscalls_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ func tidExists(tid int) (exists, supported bool, err error) {
if err != nil {
return false, false, err
}
status, err := io.ReadAll(os.NewFile(uintptr(fd), statusFile))
f := os.NewFile(uintptr(fd), statusFile)
defer f.Close()
status, err := io.ReadAll(f)
if err != nil {
return false, false, err
}
Expand Down

0 comments on commit 84b1182

Please sign in to comment.