Documentation
¶
Overview ¶
Package gproc implements management and communication for processes.
进程管理.
Index ¶
- func IsChild() bool
- func PPid() int
- func PPidOS() int
- func Pid() int
- func Send(pid int, data []byte, group ...string) error
- func SetPPid(ppid int) error
- func Shell(cmd string, out io.Writer, in io.Reader) error
- func ShellExec(cmd string, environment ...[]string) (string, error)
- func ShellRun(cmd string) error
- func StartTime() time.Time
- func Uptime() int
- type Manager
- func (m *Manager) AddProcess(pid int)
- func (m *Manager) Clear()
- func (m *Manager) GetProcess(pid int) *Process
- func (m *Manager) KillAll() error
- func (m *Manager) NewProcess(path string, args []string, environment []string) *Process
- func (m *Manager) Pids() []int
- func (m *Manager) Processes() []*Process
- func (m *Manager) RemoveProcess(pid int)
- func (m *Manager) Send(data []byte)
- func (m *Manager) SendTo(pid int, data []byte) error
- func (m *Manager) SignalAll(sig os.Signal) error
- func (m *Manager) Size() int
- func (m *Manager) WaitAll()
- type Msg
- type Process
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShellExec ¶
阻塞执行shell指令,并返回输出结果(如果需要异步,请使用goroutine)
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
进程管理器
func (*Manager) NewProcess ¶
创建一个进程(不执行)
type Msg ¶
type Msg struct { SendPid int `json:"spid"` // 发送进程ID RecvPid int `json:"rpid"` // 接收进程ID Group string `json:"group"` // 分组名称 Data []byte `json:"data"` // 原始数据 }
进程通信数据结构
type Process ¶
子进程
func NewProcess ¶
创建一个进程(不执行)
func (*Process) Release ¶
Release releases any resources associated with the Process p, rendering it unusable in the future. Release only needs to be called if Wait is not.
func (*Process) Signal ¶
Signal sends a signal to the Process. Sending Interrupt on Windows is not implemented.
Click to show internal directories.
Click to hide internal directories.