• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: rusage data for another process?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rusage data for another process?


  • Subject: Re: rusage data for another process?
  • From: Terry Lambert <email@hidden>
  • Date: Tue, 11 Dec 2007 15:07:15 -0800

Actually, parsing ps output if you use -o to control the formating output options, is pretty portable. The "ps" command is mandated by POSIX, so there's not a huge amount of room for reinterpretation, unless the standards themselves change. Of course you should limit yourself to the formatting options that are specified by:

	<http://www.opengroup.org/onlinepubs/009695399/utilities/ps.html>



-- Terry

On Dec 11, 2007, at 6:22 AM, Norm Green wrote:
I'm porting an application to Darwin that currently runs on Solaris, HPUX, AIX and Linux. Getting the process data by calling "ps" or by accessing the low-level and unstable interfaces are my least preferred options.

It would be nice if Darwin had a stable API for getting performance data of another process without disturbing that other process, just as these other UNIX systems do.

Norm Green

-----Original Message-----
From: Finlay Dobbie [mailto:email@hidden]
Sent: Tuesday, December 11, 2007 5:20 AM
To: Terry Lambert
Cc: email@hidden
Subject: Re: rusage data for another process?

On Dec 10, 2007 11:33 PM, Terry Lambert <email@hidden> wrote:
> On Dec 10, 2007, at 3:14 PM, Steve Thompson wrote:
> > On Sun, 9 Dec 2007, Norm Green wrote:
> >> Is there a way to get the data returned by getrusage() for another
> >> process?
> >
> > I also need this functionality, as least insofar as the CPU usage
> > fields are concerned.
>
> Generally, there is no way to get this information for another
> process, unless it's your child process, and it has terminated, or
> unless it is for yourself.
>
> The most correct approach is to ask the other process to make the
> call, and then tell you, simce time is not really accounted for all
> your threads until you make the call (the BSD getrusage() output is
> more or less synthetic).


If you're absolutely desperate, you could either:

1. parse the output of ps
2. use the same approach that ps does (fiddling with the relevant
mach_tasks, look at the adv_cmds project)

Of course, both of these are fragile and subject to breakage at any
point in the future.

 -- Finlay
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >RE: rusage data for another process? (From: Norm Green <email@hidden>)

  • Prev by Date: Re: CFLite Leopard CF-476
  • Next by Date: Re: getrusage only partially working?
  • Previous by thread: RE: rusage data for another process?
  • Next by thread: Building Darwin to boot on multi-processor PowerMac G5 QUAD
  • Index(es):
    • Date
    • Thread