GNOME Bugzilla – Bug 750494
[PATCH] Do not depend on /proc to read process arguments on FreeBSD
Last modified: 2015-06-07 13:17:10 UTC
FreeBSD systems usually don't have /proc mounted. We can use sysctl instead of /proc, so we don't have to ask all FreeBSD users to mount it. https://www.freebsd.org/doc/en/articles/linux-users/procfs.html
Created attachment 304699 [details] [review] screen: Get process arguments without /proc on FreeBSD
Is this specific for freebsd, or would the same code also work on (some of) the other bsds?
Created attachment 304703 [details] [review] screen: Get process arguments without /proc on FreeBSD and DragonFlyBSD It is specific for FreeBSD and DragonFlyBSD although it seems DragonFlyBSD have /proc mounted by default. NetBSD also have /proc mounted, so the old code should work. OpenBSD doesn't have /proc mounted, and we cannot reuse FreeBSD code there. There is code in gnome-shell src/shell-global.c doing similar things for OpenBSD.
Comment on attachment 304703 [details] [review] screen: Get process arguments without /proc on FreeBSD and DragonFlyBSD Is the data returned by sysctl guaranteed to be \0-terminated? And is the \0 included in the len (otherwise you'd need to malloc len+1) ?
> OpenBSD doesn't have /proc mounted, and we cannot reuse FreeBSD code there. > There is code in gnome-shell src/shell-global.c doing similar things for > OpenBSD. I think you can add __OpenBSD__ within the ifdef block. AFAIKS, it should work as is.
Created attachment 304723 [details] [review] screen: Get process arguments without /proc on FreeBSD and OpenBSD (In reply to Christian Persch from comment #4) > Comment on attachment 304703 [details] [review] [review] > screen: Get process arguments without /proc on FreeBSD and DragonFlyBSD > > Is the data returned by sysctl guaranteed to be \0-terminated? And is the \0 > included in the len (otherwise you'd need to malloc len+1) ? Yes, the data format returned by sysctl is the same as the format of /proc/<pid>/cmdline on FreeBSD, so it is \0-terminated. \0 is included in len. https://man.freebsd.org/sysctl(3) (In reply to Antoine Jacoutot from comment #5) > > OpenBSD doesn't have /proc mounted, and we cannot reuse FreeBSD code there. > > There is code in gnome-shell src/shell-global.c doing similar things for > > OpenBSD. > > I think you can add __OpenBSD__ within the ifdef block. AFAIKS, it should > work as is. I updated the patch to include OpenBSD. The patch is untested because I don't have an OpenBSD GNOME system.
Comment on attachment 304723 [details] [review] screen: Get process arguments without /proc on FreeBSD and OpenBSD Thanks!
(In reply to Christian Persch from comment #7) > Comment on attachment 304723 [details] [review] [review] > screen: Get process arguments without /proc on FreeBSD and OpenBSD > > Thanks! Tested and working perfectly on OpenBSD. Thanks for the patch!
Attachment 304723 [details] pushed as fd5cdb7 - screen: Get process arguments without /proc on FreeBSD and OpenBSD