SURFEX v8.1
General documentation of Surfex
getpidinfo.c
Go to the documentation of this file.
1 #ifdef VPP
2 #include <stdio.h>
3 #include <sys/param.h>
4 #include <sys/types.h>
5 #include <stropts.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8 #include <unistd.h>
9 #include <sys/procfs.h>
10 #include <sys/proc.h>
11  /*********************************/
12 void getpidinfo_ (
13  int *pid /*********************************/
14  )
15 
16  {
17  int fid;
18  int ipid;
19  int ierr;
20  int namelen;
21  char *pname = "/proc/xxxxx";
22  static prpsinfo_t info;
23  static proc_t proc;
24  long vrtsize;
25  int stksize;
26  u_int brksize;
27  long cpu_time;
28 
29  if (*pid != 0)
30  { ipid = *pid;
31  sprintf (pname,"/proc/%5.5d",ipid); }
32  else
33  { ipid = getpid();
34  sprintf (pname,"/proc/%5.5d",ipid); }
35 
36  fid = open (pname, O_RDONLY, 0);
37  ioctl (fid, PIOCPSINFO, (char *)&info);
38  ioctl (fid, PIOCGETPR, (char *)&proc);
39  close (fid);
40 
41  vrtsize = info.pr_size;
42  vrtsize = vrtsize*32*1024;
43  stksize = proc.p_stksize;
44  brksize = proc.p_brksize;
45  cpu_time = info.pr_time.tv_sec + info.pr_time.tv_nsec*0.0000000001;
46 
47  fprintf(stderr,"%-5s %-12s ","Pid","StackSize");
48  fprintf(stderr,"%-12s %-12s ","HeapSize","VirtualSize");
49  fprintf(stderr,"%-5s \n","Time");
50  fprintf(stderr,"%-5d %-12d ",ipid,stksize);
51  fprintf(stderr,"%-12d %-12d ",brksize,vrtsize);
52  fprintf(stderr,"%-5d \n",cpu_time);
53 
54  } /* getpidinfo */
55 #endif
void getpidinfo_(int *pid)
Definition: getpidinfo.c:12
pid_t pid
Definition: opfla_perfmon.c:22