Re: Libprocstat printing warnings & errors

From: Adrian Chadd <adrian_at_freebsd.org>
Date: Wed, 13 Aug 2025 14:36:54 UTC
hi!

On Mon, 11 Aug 2025 at 09:21, Andrew Wood <andrew1tree@gmail.com> wrote:

> Hi all,
>
> Is it normal that a library will print errors/warnings in addition to
> setting an error/errno value on functions whose purpose isn't printing?
> I've been working with libprocstat lately and the program I'm writing is
> prone to checking processes that no longer exist a lot of the time (but is
> built to handle this), but I'm disappointed about the fact that I've
> seemingly got to choose between having my stderr riddled with warnings and
> disabling my ability to use the err/warn function suite (by calling
> err_set_file to set it to /dev/null). I'd much prefer if there were a
> separate function for finding out what an error was, like perhaps a
> procstat_strerror function? It seems perfectly doable given the state
> tracking that's already done in the procstat struct. Are there any design
> considerations to explain why a data-fetching would choose to print
> warnings without any request to, rather than let the programmer decide
> whether it's worth printing anything? Is this something I could change and
> make a PR for and just let any discussion over it happen there, or is there
> some person or group I need to talk to about this?
>

Yes, absolutely; I think it'd be fine to change the library to make warn()
optional. Please do put up a PR and a diff and let's see where it goes!



-adrian


>
> Apologies if this isn't the right spot to vent about this, I'm not sure
> where the proper place is.
>