mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
/proc (Solaris). * config/procfs.m4: Add psinfo check * config/config.psinfo.c: New file. * Source/NSProcessInfo.m (+load): Read from psinfo if we can. (Based on patch #4234 from Jeremy Bettis, with some modifications). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21634 72102866-910b-0410-8b05-ffd578937521
34 lines
731 B
C
34 lines
731 B
C
/*
|
|
* Check to see if we can read the psinfo struct
|
|
*/
|
|
/*
|
|
Copyright (C) 2005 Free Software Foundation
|
|
|
|
Copying and distribution of this file, with or without modification,
|
|
are permitted in any medium without royalty provided the copyright
|
|
notice and this notice are preserved.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <procfs.h>
|
|
int main()
|
|
{
|
|
char *proc_file_name = NULL;
|
|
FILE *ifp;
|
|
psinfo_t pinfo;
|
|
char **vectors;
|
|
int i, count;
|
|
|
|
// Read commandline
|
|
proc_file_name = (char*)malloc(sizeof(char) * 2048);
|
|
sprintf(proc_file_name, "/proc/%d/psinfo", (int) getpid());
|
|
|
|
ifp = fopen(proc_file_name, "r");
|
|
if (ifp == NULL)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
fread(&pinfo, sizeof(pinfo), 1, ifp);
|
|
fclose(ifp);
|
|
return 0;
|
|
}
|