1
0
mirror of https://github.com/golang/go synced 2024-11-24 02:30:12 -07:00

runtime/testdata/testprog: close files in the tidExists GCFairness func

Signed-off-by: guoguangwu <guoguangwug@gmail.com>
This commit is contained in:
guoguangwu 2024-04-19 09:05:50 +08:00
parent 334ce51004
commit 84b1182233
2 changed files with 5 additions and 1 deletions

View File

@ -73,6 +73,8 @@ func GCFairness() {
fmt.Println("OK") fmt.Println("OK")
return return
} }
defer f.Close()
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)

View File

@ -30,7 +30,9 @@ func tidExists(tid int) (exists, supported bool, err error) {
if err != nil { if err != nil {
return false, false, err 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 { if err != nil {
return false, false, err return false, false, err
} }