File: config.psinfo.c

package info (click to toggle)
gnustep-base 1.26.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 27,260 kB
  • sloc: objc: 204,878; ansic: 32,160; sh: 157; makefile: 128; cpp: 122; xml: 32
file content (34 lines) | stat: -rw-r--r-- 731 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * 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;
}