Skip to content

Commit 27235d3

Browse files
committed
Fix jobs segment
The jobs segment needs to use the parent PID of powerline-go's parent PID. This uses the logic from Powerline-Shell.
1 parent 2489780 commit 27235d3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

segment-jobs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import (
1111
func segmentJobs(p *powerline) {
1212
nJobs := -1
1313

14-
ppid := os.Getppid()
15-
out, _ := exec.Command("ps", "-a", "-f", "-o", "ppid").Output()
14+
pppid_out, _ := exec.Command("ps", "-p", fmt.Sprintf("%d", os.Getppid()), "-oppid=").Output()
15+
pppid, _ := strconv.ParseInt(strings.TrimSpace(string(pppid_out)), 10, 64)
16+
out, _ := exec.Command("ps", "-a", "-oppid=").Output()
1617
processes := strings.Split(string(out), "\n")
1718
for _, processPpidStr := range processes {
1819
processPpid, _ := strconv.ParseInt(strings.TrimSpace(processPpidStr), 10, 64)
19-
if int(processPpid) == ppid {
20+
if int(processPpid) == int(pppid) {
2021
nJobs++
2122
}
2223
}

0 commit comments

Comments
 (0)