Linux系统调用--getrusage函数详解

【getrusage系统调用】    

    功能描述:

    获取进程的资源使用信息。

    用法:

    #include

    #include

    int getrusage(int who, struct rusage *usage);    

    参数:

    who:可能选择有

    RUSAGE_SELF:获取当前进程的资源使用信息。

    RUSAGE_CHILDREN:获取子进程的资源使用信息。

    usage:指向存放资源使用信息的结构指针

    struct rusage {

     struct timeval ru_utime; /* user time used */

     struct timeval ru_stime; /* system time used */

     long ru_maxrss; /* maximum resident set size */

     long ru_ixrss; /* integral shared memory size */

     long ru_idrss; /* integral unshared data size */

     long ru_isrss; /* integral unshared stack size */

     long ru_minflt; /* page reclaims */

     long ru_majflt; /* page faults */

     long ru_nswap; /* swaps */

     long ru_inblock; /* block input operations */

     long ru_oublock; /* block output operations */

     long ru_msgsnd; /* messages sent */

     long ru_msgrcv; /* messages received */

     long ru_nsignals; /* signals received */

     long ru_nvcsw; /* voluntary context switches */

     long ru_nivcsw; /* involuntary context switches */

    };

    返回说明:

    成功执行时,返回0。失败返回-1,errno被设为以下的某个值

    EFAULT:usage指针指向的空间不可访问

    EINVAL:who参数无效


你可能感兴趣的:(Linux系统调用--getrusage函数详解)