After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 750494 - [PATCH] Do not depend on /proc to read process arguments on FreeBSD
[PATCH] Do not depend on /proc to read process arguments on FreeBSD
Status: RESOLVED FIXED
Product: gnome-terminal
Classification: Core
Component: general
git master
Other FreeBSD
: Normal normal
: ---
Assigned To: GNOME Terminal Maintainers
GNOME Terminal Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-06-06 16:06 UTC by Ting-Wei Lan
Modified: 2015-06-07 13:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screen: Get process arguments without /proc on FreeBSD (1.68 KB, patch)
2015-06-06 16:06 UTC, Ting-Wei Lan
none Details | Review
screen: Get process arguments without /proc on FreeBSD and DragonFlyBSD (1.94 KB, patch)
2015-06-06 17:19 UTC, Ting-Wei Lan
none Details | Review
screen: Get process arguments without /proc on FreeBSD and OpenBSD (2.70 KB, patch)
2015-06-07 10:53 UTC, Ting-Wei Lan
committed Details | Review

Description Ting-Wei Lan 2015-06-06 16:06:18 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
Comment 1 Ting-Wei Lan 2015-06-06 16:06:56 UTC
Created attachment 304699 [details] [review]
screen: Get process arguments without /proc on FreeBSD
Comment 2 Christian Persch 2015-06-06 16:37:22 UTC
Is this specific for freebsd, or would the same code also work on (some of) the other bsds?
Comment 3 Ting-Wei Lan 2015-06-06 17:19:35 UTC
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 4 Christian Persch 2015-06-06 19:00:51 UTC
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) ?
Comment 5 Antoine Jacoutot 2015-06-06 21:50:14 UTC
> 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.
Comment 6 Ting-Wei Lan 2015-06-07 10:53:07 UTC
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 7 Christian Persch 2015-06-07 11:10:03 UTC
Comment on attachment 304723 [details] [review]
screen: Get process arguments without /proc on FreeBSD and OpenBSD

Thanks!
Comment 8 Antoine Jacoutot 2015-06-07 13:12:59 UTC
(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!
Comment 9 Ting-Wei Lan 2015-06-07 13:16:34 UTC
Attachment 304723 [details] pushed as fd5cdb7 - screen: Get process arguments without /proc on FreeBSD and OpenBSD