-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* All context-less wrapping functions (the ones without WithContext suffix) were moved into process.go since they all are the same. * Call context is now passed to all underlying functions in *WithContext() functions. * All common *BSD bits were moved to process_bsd.go. * Process.Tgid() method lacked a WithContext counterpart, so Process.TgidWithContext() was added for uniformity. * NewProcessWithContext() function was added since NewProcess() is used a lot throughout the module, and there is no way to pass a context to it. This is a part of #761 effort.
- Loading branch information
Sergey Vinogradov
committed
Oct 12, 2020
1 parent
b94f262
commit 065e609
Showing
9 changed files
with
368 additions
and
1,146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// +build darwin freebsd openbsd | ||
|
||
package process | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"encoding/binary" | ||
|
||
"github.com/shirou/gopsutil/cpu" | ||
"github.com/shirou/gopsutil/internal/common" | ||
"github.com/shirou/gopsutil/net" | ||
) | ||
|
||
type MemoryInfoExStat struct{} | ||
|
||
type MemoryMapsStat struct{} | ||
|
||
func (p *Process) TgidWithContext(ctx context.Context) (int32, error) { | ||
return 0, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) CwdWithContext(ctx context.Context) (string, error) { | ||
return "", common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) { | ||
return 0, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) { | ||
return 0, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func parseKinfoProc(buf []byte) (KinfoProc, error) { | ||
var k KinfoProc | ||
br := bytes.NewReader(buf) | ||
err := common.Read(br, binary.LittleEndian, &k) | ||
return k, err | ||
} |
Oops, something went wrong.