Page MenuHomeFreeBSD

top: add -p option and p command to only show a single process
ClosedPublic

Authored by novel on May 20 2018, 2:55 PM.
Tags
None
Referenced Files
F132244496: D15501.id42768.diff
Wed, Oct 15, 3:33 AM
F132244485: D15501.id.diff
Wed, Oct 15, 3:33 AM
F132244481: D15501.id43270.diff
Wed, Oct 15, 3:33 AM
F132244473: D15501.id42915.diff
Wed, Oct 15, 3:33 AM
F132244472: D15501.id42914.diff
Wed, Oct 15, 3:33 AM
F132203486: D15501.diff
Tue, Oct 14, 6:22 PM
Unknown Object (File)
Thu, Oct 9, 5:25 AM
Unknown Object (File)
Wed, Oct 8, 11:37 AM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

novel retitled this revision from top: add -pp option and p command to only show a single process to top: add -p option and p command to only show a single process.May 20 2018, 2:56 PM
top/top.c
1229–1230 ↗(On Diff #42768)

Personally, I like declaring variables close to the use, but its atypical in freebsd code. Lets see if we could sneak it in. :-p

top/top.xs
20 ↗(On Diff #42768)

this should now just be a .1 file. Same change though

top/utils.c
480 ↗(On Diff #42768)

Can we use a named constant for 23? Also are we sure we want to quit and not generate an error message?

also, I prefer braces even for single line ifs.

485 ↗(On Diff #42768)

ditto to above

492 ↗(On Diff #42768)

ditto: lets use a named constant?

  • Use constant for exit code 23,
  • Move manpage changes from top.xs to top.1,
  • Proper error handling in find_pid().
novel added inline comments.
top/utils.c
480 ↗(On Diff #42768)

Done. 23 is also used in other places, so updated those as well. Also added an error message.

485 ↗(On Diff #42768)

I re-wrote this chunk a bit. As we request specific pid from kvm_getprocs(), it's normal if it returns NULL, should not exit in this case and let the caller of find_pid() handle the invalid pid.

I've also updated kvm_open() call to set errstr to NULL as we generate our own messages for when pid was not found.

Also, I noticed as I leak kvm_t because not calling kvm_close(), should be fixed now as well.

492 ↗(On Diff #42768)

That's actually a debug leftover, removed.

This revision is now accepted and ready to land.May 24 2018, 5:59 AM
This revision was automatically updated to reflect the committed changes.