mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-26 13:48:59 +08:00
Merge pull request #1267 from easyops-cn/master
fix(process): fix OpenFilesWithContext panic problem
This commit is contained in:
commit
7de7d48ef6
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user