getrusage

Is getrusage broken in Linux (2.6.30)

与世无争的帅哥 提交于 2019-11-29 00:12:43
This code void print_usage(char * msg) { struct rusage usage; getrusage(RUSAGE_SELF, &usage); printf("Limits: %s\n", msg); printf(" %s, %li\n", " maximum resident set size " , usage.ru_maxrss ); printf(" %s, %li\n", " integral shared memory size " , usage.ru_ixrss ); printf(" %s, %li\n", " integral unshared data size " , usage.ru_idrss ); printf(" %s, %li\n", " integral unshared stack size " , usage.ru_isrss ); printf(" %s, %li\n", " page reclaims " , usage.ru_minflt ); printf(" %s, %li\n", " page faults " , usage.ru_majflt ); printf(" %s, %li\n", " swaps " , usage.ru_nswap ); printf(" %s, %li

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

落花浮王杯 提交于 2019-11-27 15:49:44
问题 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 prints the values, but I would like to know if I am doing something wrong. Thanks. printf("%ld.%6ld\n",usage.ru_stime); printf("%ld.%6ld\n",usage.ru_utime); where usage is of type typedef struct{ struct timeval ru_utime; /* user time used */ struct