[procps] Re: Using reap and get

  • From: Jim Warner <james.warner@xxxxxxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Wed, 4 Jan 2017 17:32:40 -0600

On 01/04/2017 05:09 PM, Craig Small wrote:

I've just updated the manual pages to document the pids API. I was
looking through and saw we have two ways of accessing the information,
reap and get. Looking across all the structures, this is what we have:

diskstats: get(vmstat) and reap(unused)
meminfo: get(unused)
pids: get(pgrep,pidof) and reap(w,skill,top,ps)
slabinfo: get(unused) and reap(slabinfo,vmstat)
stat: get(unused) and reap(top)
vmstat: get(unused)

To me it seems a little odd to have two functions that almost do the
same thing.  Do you think it might be worthwhile to convert the
duplicates to just use reap and retire the get function for the ones
that have a duplicate? It would only mean changing vmstat, pgrep and
pidof and none of them are doing anything special.

Might be even worth just using the reap functionality but calling it
get, but that's a second step.

Hi Craig,

They (get/reap) don't do the same thing.

One returns a single result and the other returns a bunch of results.

One deals with an extremely simple struct (or no struct with the GET macro) and the other deals with more involved structures (and almost requires the use of the VAL macro).

Please keep in mind that newlib is (and should) not be designed for our exclusive use.

I would vote to keep all three accessors: get, select and reap.

Regards,

Jim

Other related posts: