From 3cd259698f71e859faec424d162208df525f2f4e Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 4 Mar 2022 16:14:22 +0800 Subject: [PATCH] fix(process): fix OpenFilesWithContext panic problem --- process/process_windows.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/process/process_windows.go b/process/process_windows.go index d7bb53e..d6023cf 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -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 } @@ -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 }