Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Add pgrp and sid for processes #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions process_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
type DarwinProcess struct {
pid int
ppid int
pgrp int
sid int
binary string
}

Expand All @@ -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
}
Expand Down Expand Up @@ -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),
}
}
Expand Down
8 changes: 8 additions & 0 deletions process_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions process_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions process_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type PROCESSENTRY32 struct {
type WindowsProcess struct {
pid int
ppid int
pgrp int
sid int
exe string
}

Expand All @@ -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
}
Expand Down