Date: Thu, 02 Dec 2021 16:46:03 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 260174] libprocstat's i386 procstat_getfiles() fails on amd64 Message-ID: <bug-260174-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260174 Bug ID: 260174 Summary: libprocstat's i386 procstat_getfiles() fails on amd64 Product: Base System Version: 13.0-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: damjan.jov@gmail.com An i386 binary calling procstat_getfiles() on amd64 always gets NULL return= ed and errno=3D=3D0, even though libutil's kinfo_getfile() works. The same cod= e built as an amd64 binary works with both. I don't like procstat_getfiles() anyway, and won't be using it, at almost 1 millisecond per call it's ridiculously slow, and its linked list is less us= eful and costlier to build than kinfo_getfile()'s array. Just thought it would be good to document this issue for others that run into it. cc -m32 file.c -o proctest -lprocstat #include <sys/types.h> #include <sys/param.h> #include <sys/queue.h> #include <sys/sysctl.h> #include <sys/socket.h> #include <sys/user.h> #include <libprocstat.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { struct procstat *procstat =3D NULL; unsigned int count; struct kinfo_proc *kp =3D NULL; struct filestat_list *files =3D NULL; struct filestat *fs =3D NULL; char *ret =3D NULL; printf("starting...\n"); procstat =3D procstat_open_sysctl(); if (!procstat) { fprintf(stderr, "couldn't open procstat\n"); goto end; } printf("opened procstat\n"); kp =3D procstat_getprocs( procstat, KERN_PROC_PID, getpid(), &count ); if (!kp || count !=3D 1) { fprintf(stderr, "getprocs failed\n"); goto end; } printf("got proc, now looking up files...\n"); files =3D procstat_getfiles( procstat, kp, 0 ); if (!files) { fprintf(stderr, "getfiles failed, errno %d\n", errno); goto end; } STAILQ_FOREACH( fs, files, next ) { printf("%d -> %s\n", fs->fs_fd, fs->fs_path); } end: return 0; } --=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-260174-227>