Skip to content

adds CmdLine() exception handler#5

Merged
juliusv merged 1 commit intomasterfrom
unknown repository
Apr 28, 2015
Merged

adds CmdLine() exception handler#5
juliusv merged 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Apr 27, 2015

If /proc/pid/cmdline has no content, slice operation of the 'data' will be panicked. (e.g. kernel threads)

@beorn7
Copy link
Copy Markdown
Member

beorn7 commented Apr 27, 2015

👍 but let's have @grobie take a look to verify.

proc.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do: "could not read cmdline for pid: %d"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, should this really return an error, or just an empty command-line?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, just return an empty command-line make more sense to me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Curious - are you using this function from somewhere? Seems like the "prometheus" github org is not even using it anywhere yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for an empty string

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'm building some kind of system event listener including docker and kernel proc events.
As a part of the listener, I found this repository for proc fs reader.
And we're planning to use prometheus for our system metric server. :)

@grobie
Copy link
Copy Markdown
Member

grobie commented Apr 27, 2015

Please add a test case as well.

@ghost
Copy link
Copy Markdown
Author

ghost commented Apr 27, 2015

I added a test case for an empty cmdline file.

proc.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should return []string{}, nil here, as the assumption in go for type, error return signatures is usually: if err is nil then the returned type is an initialized value.

@ghost
Copy link
Copy Markdown
Author

ghost commented Apr 27, 2015

Thanks for your comment.

@grobie
Copy link
Copy Markdown
Member

grobie commented Apr 27, 2015

👍 Great, thanks! Now comes the last pedantry thingy ;), we usually tend to squash our commits together at the end of a PR review, so that we have only a few coherent commits with all changes to code+tests+fixtures together. I'll merge immediately after squashing them to a nice commit.

@ghost
Copy link
Copy Markdown
Author

ghost commented Apr 27, 2015

👍 Great!

@juliusv
Copy link
Copy Markdown
Member

juliusv commented Apr 28, 2015

@jhseol Hey hey, but the commits are still not squashed - could you squash them? Then we'll merge :)

@ghost
Copy link
Copy Markdown
Author

ghost commented Apr 28, 2015

Commits are squashed. Is it okay to merge?

@juliusv
Copy link
Copy Markdown
Member

juliusv commented Apr 28, 2015

@jhseol Hmm, somehow the "Update example" commit by @audebert made it into your squashed commits (https://github.com/prometheus/procfs/pull/5/commits), but under a different SHA than in master. This should fix it:

git checkout master
git reset --hard origin/master
git cherry-pick 99d4f8f  # The one commit we're actually interested in.
git push -f origin master

@ghost
Copy link
Copy Markdown
Author

ghost commented Apr 28, 2015

Commits are squashed again. I'm not sure how "Update example" commit was squashed with my commit. :(

@juliusv
Copy link
Copy Markdown
Member

juliusv commented Apr 28, 2015

@jhseol no worries - looking good now :) Thanks! Merging.

juliusv added a commit that referenced this pull request Apr 28, 2015
adds CmdLine() exception handler
@juliusv juliusv merged commit 0023c0a into prometheus:master Apr 28, 2015
juanrh pushed a commit to juanrh/procfs that referenced this pull request Aug 9, 2022
bobrik pushed a commit to bobrik/procfs that referenced this pull request Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants