[procps] Re: newlib, ps fix

  • From: Jim Warner <james.warner@xxxxxxxxxxx>
  • To: Procps-ng Mail list <procps@xxxxxxxxxxxxx>
  • Date: Wed, 26 Aug 2015 14:48:35 -0500

On 08/26/2015 07:50 AM, Craig Small wrote:

The procps_thing_read should return an error if proc isn't mounted.
There would be race conditions, for example.
Now, did we want the library to have a specific function to check for
this? Certainly if it does an output to stderr and an exit() is not
the right idea.

Hi Craig,

The current look_up_our_self() approach has the advantage of standardizing the fatal error message. Your approach forces each and every library user to invent their own (different) error message or, as is true of some of our own tools, just ignore the possibility that /proc is not mounted.

Personally, I see nothing wrong with a fatal error exit directly from the library as long as it is clearly noted. Programs like top and ps could choose to pass that hurdle before any other processing. Maybe sonething like:
procps_fatal_unmounted()

Grabbing them all at once, assuming there isn't any efficiences lost, is
preferred. It means all the start time calcs line up better.

While awaiting your reply, I undertook the conversion of Jaromir's pidof program, thinking that would be an easy next step. While I got it working with the existing newlib state, it wasn't so easy and the required code changes really piled up.

It was that experience that convinced me the pids API really needed the following additional capabilities:
. sequential 'read' as an alternative to the current 'reap'
. true vectored strings for cmdline, as a minimum

So the attached tarball contains the those library changes and some others, along with the pidof conversion. Some things to note:
. pidof has no error checking, he behaves just as before
. true string vectors were also added to cgroup & environ
. 'read' was made incompatible with 'fill' and 'reap'

In summary, I'm pretty happy with this new pids API state. But what I need are some other opinions. So, after pushing these changes, why not try your hand at converting the w program.

After that we can compare notes and maybe I'll muster the courage to tackle ps.

Regards,
Jim

Attachment: newlib-pidof-etc.tgz
Description: application/compressed-tar

Other related posts: