Date: Fri, 03 Apr 2020 15:41:23 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 245318] procstat_getprocs() noise on stderr Message-ID: <bug-245318-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D245318 Bug ID: 245318 Summary: procstat_getprocs() noise on stderr Product: Base System Version: 12.1-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: jwb@freebsd.org I think a process count of 0 in procstat_getprocs() is not necessarily an e= rror and this should not trigger a message to stderr. The code below demonstrates the issue, assuming 1000 is not part of a proce= ss group. Tweak the value if necessary. If procstat_getprocs() does not find any processes in the group, it returns= 0 via the *count argument as expected, but also prints a warning to stderr us= ing warnx(): kinfo_proc structure size mismatch (len =3D 0) The warnx() call can be found in /usr/src/lib/libprocstat/libprocstat.c. It seems to be that the action to be taken when count =3D=3D 0 should be le= ft to the caller. #include <stdio.h> #include <sysexits.h> #include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/user.h> #include <sys/sysctl.h> #include <libprocstat.h> int main(int argc,char *argv[]) { unsigned pgid =3D 1000, pid_count; struct procstat *proc_info; struct kinfo_proc *proc_list; // FILE *procstat_err; proc_info =3D procstat_open_sysctl(); // Silence warnx() // procstat_err =3D fopen("/dev/null", "w+"); // err_set_file(procstat_err); proc_list =3D procstat_getprocs(proc_info, KERN_PROC_PGRP, pgid, (unsigned *)&pid_count); // fclose(procstat_err); procstat_freeprocs(proc_info, proc_list); procstat_close(proc_info); return EX_OK; } --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-245318-227>