Skip to content

Commit

Permalink
Merge pull request #1267 from easyops-cn/master
Browse files Browse the repository at this point in the history
fix(process): fix OpenFilesWithContext panic problem
  • Loading branch information
shirou authored Mar 5, 2022
2 parents f3b7c00 + 3cd2596 commit 7de7d48
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions process/process_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,8 @@ func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, er
// release the new handle
defer windows.CloseHandle(windows.Handle(file))

fileType, _ := windows.GetFileType(windows.Handle(file))
if fileType != windows.FILE_TYPE_DISK {
fileType, err := windows.GetFileType(windows.Handle(file))
if err != nil || fileType != windows.FILE_TYPE_DISK {
continue
}

Expand All @@ -720,8 +720,8 @@ func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, er
case <-time.NewTimer(100 * time.Millisecond).C:
continue
case <-ch:
fileInfo, _ := os.Stat(fileName)
if fileInfo.IsDir() {
fileInfo, err := os.Stat(fileName)
if err != nil || fileInfo.IsDir() {
continue
}

Expand Down

0 comments on commit 7de7d48

Please sign in to comment.