Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6320011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:53:55+00:00 2026-05-24T15:53:55+00:00

Is there a function in Linux which allows me to see how much CPU

  • 0

Is there a function in Linux which allows me to see how much CPU did a process use after it finished? I need something similar to bash “time” command. I am fork()ing the process and then waiting using wait() for a child to finish. The way of accurately measuring “real” time (actual time elapsed between fork() and exit()), even when wait() was called a long after the child process became zombie is also welcome, but I’m not sure if its possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:53:56+00:00Added an answer on May 24, 2026 at 3:53 pm

    Sure, wait3 and wait4 have you covered. Alternatively (and more portably) you could use getrusage(2).

    The wait3() and wait4() system calls are similar to waitpid(2), but
    additionally return resource usage information about the child in the
    structure pointed to by rusage.

    Example: wait3

    struct rusage usage;
    wait3(&status, 0, &usage);
    

    Example: getrusage

    Of course, wait3 and wait4 are just a convenience. So you could use getrusage:

    getrusage(RUSAGE_CHILDREN, &usage);
    

    The disadvantage is that this tells you the resources used by ALL the terminated children.

    So, once you get it, what do you do with rusage ? struct rusage has the following form:

    struct rusage {
        struct timeval ru_utime; /* user CPU time used */
        struct timeval ru_stime; /* system CPU time used */
        /* More. */
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a function in the C Library under Linux which can set the
Is there any function in C on linux by which we can query MX
In Linux when I run the destroy function on java.lang.Process object (Which is true
I have like 50 different php files which all use the mail function. After
Is there an API function on Linux (kernel 2.6.20) which can be used to
for a TCP Server Class I need a Linux function, which does what SetHandleInformation(,
I need a function which will create a file with fixed size in linux.
I am using Linux and there is a custom function of which returns an
Is there a reason why most function definition in device driver in linux code
Is there a rough equivalent to the Linux/Unix stdio.h popen() function in the Win32

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.