Questions tagged [rusage]

10 questions
22
votes
6 answers

UNIX Programming. struct timeval how to print it (C-programming)

I am trying to print a value of type timeval. Actually I am able to print it, but I get the following warning: Multiple markers at this line format ‘%ld’ expects type ‘long int’, but argument 2 has type ‘struct timeval’ The program compiles and it…
user69514
  • 26,935
  • 59
  • 154
  • 188
3
votes
1 answer

How getrusage works and What is really inside the rusage struct?

I'm trying to understand how int getrusage(int who, struct rusage* usage) works in order to calculate the running time of one my program. I red the man page, 10 times maybe, and still can't get it. Tried to find something on the web, but nothing…
Root149
  • 389
  • 1
  • 3
  • 11
2
votes
2 answers

How can adding a header increase portability? (sys/time.h)

I just noticed this line in the getrusage man page: Including is not required these days, but increases portability. (Indeed, struct timeval is defined in ) What? Since struct rusage contains struct timeval as a member,…
spraff
  • 32,570
  • 22
  • 121
  • 229
2
votes
1 answer

Measure cpu usage of child but not grandchildren

This might be an obvious thing, but I can't seem to figure out how to do it. Assuming that I spawn a process like this: popen = subprocess.Popen(args, executable=executable, bufsize=-1, …
pehrs
  • 1,481
  • 2
  • 15
  • 21
2
votes
2 answers

strange values of get rusage.maxrss on macOS and Linux

Currently i'm writing online judgment system on golang. To detect user program memory usage i've decided to analyze cmd.ProcessState.SysUsage() and check Rusage.Maxrss. Now i'm confused, because when i try to run this on my mac result of…
1
vote
1 answer

Is there any alterntive to wait3 to get rusage structure in shell scripting?

I was trying to monitor the peak memory usage of a child process.time -v is an option,but it is not working in solaris.So is there any way to get details that are in rusage structure from shell scripting?
1
vote
1 answer

getrusage() get system time, user time. Unix programming help

I am writing a shell where I need to launch several child processes at once and record the system time and user time. So far I am able to do it. The only problem is that I am using wait4 to grab the system resources used by the child program and put…
user69514
  • 26,935
  • 59
  • 154
  • 188
0
votes
1 answer

Rusage with wait4() does not show CPU time of finished child process

I have a simple function which creates a child process, waits for it to finish and prints CPU system and user time. int PrintChildProcessTime(char **arg) { pid_t pid; int status; struct rusage usage; if ((pid=fork()) == 0) { …
Dandry
  • 495
  • 12
  • 26
0
votes
2 answers

Ubuntu rusage error

I'm porting over some really old (and massive base of) code from CentOS 6 to Ubuntu 14.04. Note, I've installed the expected older version of gcc, fixed linker references, etc. My build attempt is progressing, but I'm stuck on one thing. There's a C…
csr19us
  • 105
  • 9
0
votes
1 answer

rusage() measured in seconds or millseconds?

Hi I'm trying to get the system time and user time of applications being forked by a shell. I'm just not sure what kind of time I'm getting, seconds? milliseconds? Does anybody know? printf("System time: %ld.%06ld sec\n",usage.ru_stime.tv_sec,…
user69514
  • 26,935
  • 59
  • 154
  • 188