On Wednesday, October 5, 2011 12:41 CEST, David Chisnall<theraven@sucs.org>
wrote:
On 5 Oct 2011, at 11:18, Sebastian Reitenbach wrote:
Besides its ugly, and forces one more step to do on the user before he can use
gnustep programs, is there any good advantage of using procfs instead of the
fake main?
Will stuff be noticeably faster, more stable, whatever?
The fake main stuff is fragile, because it will break if the compilation unit
containing main() does not include the GNUstep headers. For example, if you
have a main.c that then calls into some Objective-C stuff later, it won't work.
On FreeBSD, we use kvm to get this, with some slight fudges. I don't know if
the same code path works on OpenBSD - you can try it (you may need to enable
kvm in configure).
| #include "./config/config.proccmd.c"
configure:21341: result: no
configure:21351: checking for kvm_getenvv in -lkvm
configure:21386: clang -o conftest -O2 -pipe -g -O0 -I/usr/local/include
-I/usr/local/include -I/usr/local/include -I/usr/local/include
-L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib conftest.c
-lkvm -lpthr
ead -lz>&5
configure:21393: $? = 0
configure:21414: result: yes
configure:21426: checking if we can access kernel memory
configure:21445: clang -o conftest -O2 -pipe -g -O0 -I/usr/local/include
-I/usr/local/include -I/usr/local/include -I/usr/local/include
-L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib conftest.c
-lkvm -lpthre
ad -lz>&5
configure:21449: $? = 0
configure:21455: ./conftest
NSProcessInfo: /dev/null: not physical memory device
configure:21459: $? = 1
$ cat ./config/config.kvmopen.c
/*
* Check to see if we can open the kernel memory.
*/
#include<stdio.h>
#include<kvm.h>
#include<fcntl.h>
#include<sys/param.h>
#include<sys/sysctl.h>
int main()
{
kvm_t *kptr = NULL;
/* open the kernel */
kptr = kvm_open(NULL, "/dev/null", NULL, O_RDONLY, "NSProcessInfo");
return (kptr != NULL) ? 0 : 1;
}
The configure gets upset about the /dev/null
changing the /dev/null to NULL, and rerunning configure, I get this warning:
configure:21341: result: no
configure:21351: checking for kvm_getenvv in -lkvm
configure:21386: clang -o conftest -O2 -pipe -g -O0 -I/usr/local/include
-I/usr/local/include -I/usr/local/include -I/usr/local/include
-L/usr/local/lib -L/usr/lo
cal/lib -L/usr/local/lib -L/usr/local/lib conftest.c -lkvm -lpthread -lz>&5
configure:21393: $? = 0
configure:21414: result: yes
configure:21426: checking if we can access kernel memory
configure:21445: clang -o conftest -O2 -pipe -g -O0 -I/usr/local/include
-I/usr/local/include -I/usr/local/include -I/usr/local/include
-L/usr/local/lib -L/usr/lo
cal/lib -L/usr/local/lib -L/usr/local/lib conftest.c -lkvm -lpthread -lz>&5
configure:21449: $? = 0
configure:21455: ./conftest
NSProcessInfo: /dev/mem: Permission denied
configure:21459: $? = 1
configure: program exited with status 1
since a normal user is not in group kmem:
crw-r----- 1 root kmem 2, 1 Sep 29 13:54 /dev/kmem
crw-r----- 1 root kmem 2, 0 Sep 29 13:54 /dev/mem