Finish ss example mapping connections to pids#151
Finish ss example mapping connections to pids#151adrianlzt wants to merge 1 commit intoelastic:masterfrom
Conversation
ea41410 to
3893a52
Compare
|
@elastic/agent |
|
@fearful-symmetry can you take a look? |
|
|
||
| fds, err := pidDir.Readdirnames(0) | ||
| if err != nil { | ||
| continue |
There was a problem hiding this comment.
For errors like this, where there's no expectation that they might fail, we might want to actually fail, or at least comment if we expect them to fail for some reason.
There was a problem hiding this comment.
It could fail if the pid has finished and the dir does not exists any more.
Failing there will generate a lot of useless "warnings" IMHO
There was a problem hiding this comment.
In which case, can we at least add a comment to clarify?
There was a problem hiding this comment.
gomacro> import "os"
gomacro> a, err := os.Open("/proc/955374/fd")
gomacro> err
<nil> // error
<--- here I kill process 955374
gomacro> a.Readdirnames(0)
[] // []string
readdirent: no such file or directory // error
gomacro>
It is commented in line 126
There was a problem hiding this comment.
Ah, I see. Considering that we can hit errors relating to non-existent PIDs in a few places, can we move that comment block in 126 out of that if block and move it somewhere, perhaps before the Open call just to make the comment a little more explicit?
| for _, fd := range fds { | ||
| link, err := os.Readlink("/proc/" + string(pid) + "/fd/" + fd) | ||
| if err != nil { | ||
| continue |
Implementation similar to ss https://fossies.org/linux/iproute2/misc/ss.c
3893a52 to
c33f375
Compare
Implementation similar to ss
https://fossies.org/linux/iproute2/misc/ss.c