mitchellh / go-ps

Find, list, and inspect processes from Go (golang).
MIT License
1.46k stars 250 forks source link

"Executable names truncated #15" fix for darwin #43

Open Backerich opened 3 years ago

Backerich commented 3 years ago

There is an issue with the linux and darwin executable names beeing truncated #15 This commit is only for the darwin side, the bug was due to kinfo_proc->kp_proc.p_comm only beeing able to hold 16 Chars as it can be seen in sys/proc.h p_comm[MAXCOMLEN + 1] (MAXCOMLEN = 16) The commit is using libproc.h to get the execution path and using filepath.Base to receive only the executable name from the path Credit: The function getExePathFromPid is from here comes with a great explanation