• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

C/Linux getrusage-question

katinka

n00b
Joined
Aug 10, 2005
Messages
10
I haven't done much C-programming (or programming at all actually, except for java the last year), but here's my question:
Is there anything wrong with this tiny program?

Code:
#include <stdio.h>
#include <unistd.h>
#include <sys/resource.h>
#include <sys/time.h>

int main(void)
{
[INDENT]struct rusage self,children;
getrusage(RUSAGE_SELF,&self);
getrusage(RUSAGE_CHILDREN,&children);
double self_utime=(double)self.ru_utime.tv_sec+1.e-6*(double)self.ru_utime.tv_usec;
double self_stime=(double)self.ru_stime.tv_sec+1.e-6*(double)self.ru_stime.tv_usec;
double children_utime=(double)children.ru_utime.tv_sec+1.e-6*(double)children.ru_utime.tv_usec;
double children_stime(double)children.ru_stime.tv_sec+1.e-6*(double)children.ru_stime.tv_usec;
printf("SELF: user %f, system %f\n", self_utime, self_stime);
printf("CHILDREN: user %f, system %f\n", children_utime, children_stime);
return 0;[/INDENT]
}

One time it said a couple of million seconds on children, and I thought that was kind of weird. Now it says under a second on everything. It is supposed to give me the user and system time used by the current process, right? Anyway, I would really appreciate the help :)
 
Back
Top