getrusage(2) System Calls Manual getrusage(2) getrusage - C (libc, -lc) #include int getrusage(int who, struct rusage *usage); getrusage() who, : RUSAGE_SELF ( ). RUSAGE_CHILDREN , . , , . RUSAGE_THREAD ( Linux 2.6.26) . _GNU_SOURCE ( ). , usage; : struct rusage { struct timeval ru_utime; /* , . */ struct timeval ru_stime; /* , . */ long ru_maxrss; /* rss */ long ru_ixrss; /* */ long ru_idrss; /* */ long ru_isrss; /* */ long ru_minflt; /* ( ) */ long ru_majflt; /* ( ) */ long ru_nswap; /* */ long ru_inblock; /* */ long ru_oublock; /* */ long ru_msgsnd; /* IPC */ long ru_msgrcv; /* IPC */ long ru_nsignals; /* */ long ru_nvcsw; /* */ long ru_nivcsw; /* - */ }; ; . ( , - Linux.) : ru_utime , , timeval ( ). ru_stime , , timeval ( ). ru_maxrss ( Linux 2.6.32) This is the maximum resident set size used (in KiB). For RUSAGE_CHILDREN, this is the resident set size of the largest child, not the maximum resident set size of the process tree. ru_ixrss ( ) Linux . ru_idrss ( ) Linux . ru_isrss ( ) Linux . ru_minflt The number of page faults serviced without any I/O activity; here, I/O activity is avoided by "reclaiming" a page frame from the list of pages awaiting reallocation. ru_majflt , -. ru_nswap ( ) Linux . ru_inblock ( Linux 2.6.22) . ru_oublock ( Linux 2.6.22) . ru_msgsnd ( ) Linux . ru_msgrcv ( ) Linux . ru_nsignals ( ) Linux . ru_nvcsw ( Linux 2.6) , (, - ). ru_nivcsw ( Linux 2.6) - . 0. -1, errno . EFAULT usage . EINVAL who. attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |getrusage() | | MT-Safe | +----------------------------+----------------------------------------------------------+--------------------------+ POSIX.1-2024. POSIX.1 specifies getrusage(), but specifies only the fields ru_utime and ru_stime. RUSAGE_THREAD Linux. 4.3BSD, SVr4, SUSv1, POSIX.1-2001 XSI. Before Linux 2.6.9, if the disposition of SIGCHLD is set to SIG_IGN then the resource usages of child processes are automatically included in the value returned by RUSAGE_CHILDREN, although POSIX.1-2001 explicitly prohibits this. This nonconformance is rectified in Linux 2.6.9 and later. , , 4.3BSD Reno. Ancient systems provided a vtimes() function with a similar purpose to getrusage(). For backward compatibility, glibc (up until Linux 2.32) also provides vtimes(). All new applications should be written using getrusage(). (Since Linux 2.33, glibc no longer provides an vtimes() implementation.) execve(2). clock_gettime(2), getrlimit(2), times(2), wait(2), wait4(2), clock(3), proc_pid_stat(5), proc_pid_io(5) () Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () . Linux man-pages 6.18 8 2026 . getrusage(2)