DAOS-18563 control: Find parent process name more flexibly#17494
DAOS-18563 control: Find parent process name more flexibly#17494
Conversation
|
Ticket title is 'Check /proc/pid/comm first when getting process name' |
|
Test stage Functional on EL 8.8 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17494/1/execution/node/1011/log |
|
Test stage Test RPMs on EL 8.6 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17494/1/execution/node/1086/log |
802262d to
6a34795
Compare
|
Test stage NLT on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17494/2/testReport/ |
f4a6d8d to
c058976
Compare
kjacque
left a comment
There was a problem hiding this comment.
LGTM, comment is just a suggestion.
| } | ||
|
|
||
| return filepath.Base(pPath), nil | ||
| return string(data[:len(data)-1]), nil // trim trailing newline |
There was a problem hiding this comment.
could use strings.Trim which might eliminate the need for the comment
In some cases, it's more reliable to get the process name from /proc/$pid/comm, so prefer that with a fallback to the old method of using readlink on /proc/$pid/exe. Signed-off-by: Michael MacDonald <github@macdonald.cx>
c058976 to
3a24199
Compare
knard38
left a comment
There was a problem hiding this comment.
I have some concerns with using /proc/<pid>/comm: see my comments.
| func (p *Process) ParentProcessName() (string, error) { | ||
| pPath, err := os.Readlink(fmt.Sprintf("/proc/%d/exe", os.Getppid())) | ||
| if err != nil { | ||
| data, err := os.ReadFile(fmt.Sprintf("/proc/%d/comm", os.Getppid())) |
There was a problem hiding this comment.
From my understanding, using /proc/<pid>/comm is not reliable: if the name of the process is greater than 16 characters, it will be truncated. From my side, I prefer to process /proc/<pid>/cmdline system file which contains the full name of the executable and the arguments.
In some cases, it's more reliable to get the process name from
/proc/$pid/comm, so prefer that with a fallback to the old method
of using readlink on /proc/$pid/exe.
Signed-off-by: Michael MacDonald github@macdonald.cx