diff --git a/process.go b/process.go index 2b5e8ed..57e1b8b 100644 --- a/process.go +++ b/process.go @@ -16,6 +16,12 @@ type Process interface { // PPid is the parent process ID for this process. PPid() int + // Pgrp is the process group ID of the process + Pgrp() int + + // Sid is the session ID of the process + Sid() int + // Executable name running this process. This is not a path to the // executable. Executable() string diff --git a/process_darwin.go b/process_darwin.go index 5ee87fb..8ce55ea 100644 --- a/process_darwin.go +++ b/process_darwin.go @@ -12,6 +12,8 @@ import ( type DarwinProcess struct { pid int ppid int + pgrp int + sid int binary string } @@ -23,6 +25,14 @@ func (p *DarwinProcess) PPid() int { return p.ppid } +func (p *DarwinProcess) Pgrp() int { + return p.pgrp +} + +func (p *DarwinProcess) Sid() int { + return p.sid +} + func (p *DarwinProcess) Executable() string { return p.binary } @@ -63,9 +73,13 @@ func processes() ([]Process, error) { darwinProcs := make([]Process, len(procs)) for i, p := range procs { + pgid, _ := syscall.Getpgid(int(p.Pid)) + sid, _ := syscall.Getsid(int(p.Pid)) darwinProcs[i] = &DarwinProcess{ pid: int(p.Pid), ppid: int(p.PPid), + pgrp: pgid, + sid: sid, binary: darwinCstring(p.Comm), } } diff --git a/process_freebsd.go b/process_freebsd.go index 130acbe..3fd712c 100644 --- a/process_freebsd.go +++ b/process_freebsd.go @@ -121,6 +121,14 @@ func (p *UnixProcess) PPid() int { return p.ppid } +func (p *UnixProcess) Pgrp() int { + return p.pgrp +} + +func (p *UnixProcess) Sid() int { + return p.sid +} + func (p *UnixProcess) Executable() string { return p.binary } diff --git a/process_unix.go b/process_unix.go index cd217a8..7e16c21 100644 --- a/process_unix.go +++ b/process_unix.go @@ -29,6 +29,14 @@ func (p *UnixProcess) PPid() int { return p.ppid } +func (p *UnixProcess) Pgrp() int { + return p.pgrp +} + +func (p *UnixProcess) Sid() int { + return p.sid +} + func (p *UnixProcess) Executable() string { return p.binary } diff --git a/process_windows.go b/process_windows.go index f151974..99c58ab 100644 --- a/process_windows.go +++ b/process_windows.go @@ -42,6 +42,8 @@ type PROCESSENTRY32 struct { type WindowsProcess struct { pid int ppid int + pgrp int + sid int exe string } @@ -53,6 +55,14 @@ func (p *WindowsProcess) PPid() int { return p.ppid } +func (p *WindowsProcess) Pgrp() int { + return p.pgrp +} + +func (p *WindowsProcess) Sid() { + return p.sid +} + func (p *WindowsProcess) Executable() string { return p.exe }