fix(process): fix OpenFilesWithContext panic problem

This commit is contained in:
paul 2022-03-04 16:14:22 +08:00
parent 03f9f55571
commit 3cd259698f
1 changed files with 4 additions and 4 deletions

View File

@ -697,8 +697,8 @@ func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, er
// release the new handle // release the new handle
defer windows.CloseHandle(windows.Handle(file)) defer windows.CloseHandle(windows.Handle(file))
fileType, _ := windows.GetFileType(windows.Handle(file)) fileType, err := windows.GetFileType(windows.Handle(file))
if fileType != windows.FILE_TYPE_DISK { if err != nil || fileType != windows.FILE_TYPE_DISK {
continue continue
} }
@ -720,8 +720,8 @@ func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, er
case <-time.NewTimer(100 * time.Millisecond).C: case <-time.NewTimer(100 * time.Millisecond).C:
continue continue
case <-ch: case <-ch:
fileInfo, _ := os.Stat(fileName) fileInfo, err := os.Stat(fileName)
if fileInfo.IsDir() { if err != nil || fileInfo.IsDir() {
continue continue
} }