mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-24 13:48:56 +08:00
implement NumFDs for Windows
This commit is contained in:
parent
6c06ac987e
commit
cbc32afb65
@ -43,6 +43,7 @@ var (
|
|||||||
procGetPriorityClass = common.Modkernel32.NewProc("GetPriorityClass")
|
procGetPriorityClass = common.Modkernel32.NewProc("GetPriorityClass")
|
||||||
procGetProcessIoCounters = common.Modkernel32.NewProc("GetProcessIoCounters")
|
procGetProcessIoCounters = common.Modkernel32.NewProc("GetProcessIoCounters")
|
||||||
procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo")
|
procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo")
|
||||||
|
procGetProcessHandleCount = common.Modkernel32.NewProc("GetProcessHandleCount")
|
||||||
|
|
||||||
processorArchitecture uint
|
processorArchitecture uint
|
||||||
)
|
)
|
||||||
@ -549,7 +550,18 @@ func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitche
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
|
func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
|
||||||
return 0, common.ErrNotImplementedError
|
handle, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid))
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
defer windows.CloseHandle(handle)
|
||||||
|
|
||||||
|
var handleCount uint32
|
||||||
|
ret, _, err := procGetProcessHandleCount.Call(uintptr(handle), uintptr(unsafe.Pointer(&handleCount)))
|
||||||
|
if ret == 0 {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int32(handleCount), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
|
func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user