getrusage(2) System Calls Manual getrusage(2) getrusage - LIBRARY Standard C library (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) ( ). RUSAGE_CHILDREN , . ru_ixrss ( ) Linux . ru_idrss ( ) Linux . ru_isrss ( ) Linux . ru_minflt , -; <<>> , . 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) - . On success, zero is returned. On error, -1 is returned, and errno is set to indicate the error. EFAULT usage . EINVAL who. attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |getrusage() | | MT-Safe | +----------------------------+----------------------------------------------------------+--------------------------+ POSIX.1-2008. POSIX.1 specifies getrusage(), but specifies only the fields ru_utime and ru_stime. RUSAGE_THREAD Linux. POSIX.1-2001, SVr4, 4.3BSD. 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). /proc/pid/stat proc(5). . clock_gettime(2), getrlimit(2), times(2), wait(2), wait4(2), clock(3) Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . getrusage(2)