https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245318
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: b...@freebsd.org Reporter: j...@freebsd.org I think a process count of 0 in procstat_getprocs() is not necessarily an error and this should not trigger a message to stderr. The code below demonstrates the issue, assuming 1000 is not part of a process 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 using warnx(): kinfo_proc structure size mismatch (len = 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 == 0 should be left 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 = 1000, pid_count; struct procstat *proc_info; struct kinfo_proc *proc_list; // FILE *procstat_err; proc_info = procstat_open_sysctl(); // Silence warnx() // procstat_err = fopen("/dev/null", "w+"); // err_set_file(procstat_err); proc_list = 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; } -- You are receiving this mail because: You are the assignee for the bug. _______________________________________________ freebsd-bugs@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"