From 46ab4135cb2691020de1e0c631c84404de4984fb Mon Sep 17 00:00:00 2001 From: ZheNing Hu Date: Tue, 22 Apr 2025 17:44:24 +0800 Subject: [PATCH] feat(session): add GetPIDs interface Signed-off-by: ZheNing Hu --- sh.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sh.go b/sh.go index 532604b..7054ca9 100644 --- a/sh.go +++ b/sh.go @@ -181,6 +181,17 @@ func newEnviron(env map[string]string, inherit bool) []string { //map[string]str return environ } +func (s *Session) GetPIDs() []int { + var pids = make([]int, 0) + + for _, cmd := range s.cmds { + if cmd.Process != nil { + pids = append(pids, cmd.Process.Pid) + } + } + return pids +} + func (s *Session) appendCmd(cmd string, args []string, cwd Dir, env map[string]string) { if s.started { s.started = false