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.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

novel created this revision.May 20 2018, 2:55 PM
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
eadler added inline comments.May 22 2018, 5:25 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?

novel updated this revision to Diff 42914.May 24 2018, 5:50 AM
  • Use constant for exit code 23,
  • Move manpage changes from top.xs to top.1,
  • Proper error handling in find_pid().
novel updated this revision to Diff 42915.May 24 2018, 5:51 AM
novel marked an inline comment as done.May 24 2018, 5:57 AM
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.

eadler accepted this revision.May 24 2018, 5:59 AM
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.