• 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: Using NSPipe to get system command output
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSPipe to get system command output


  • Subject: Re: Using NSPipe to get system command output
  • From: Charlie Dickman <email@hidden>
  • Date: Mon, 13 Aug 2012 19:32:59 -0400

This is just test code to see if I can actually get the vm_stat data. It is run only under the debugger 1 or 2 steps at a time. When I have the concept down I will modify it.

No, I actually mean != 0, see below - it is the description of how reading available data from a NSFileHandleForReading...

Return Value
	 The data currently available through the receiver.

	 Discussion
	 If the receiver is a file, returns the data obtained by reading the file from the file pointer to the end of the file. If the receiver is a communications channel, reads up to a buffer of data and returns it; if no data is available, the method blocks. Returns an empty data object if the end of file is reached. Raises NSFileHandleOperationException if attempts to determine file-handle type fail or if attempts to read from the file or channel fail.

On Aug 13, 2012, at 6:09 PM, Jens Alfke wrote:

>
> On Aug 13, 2012, at 2:17 PM, Charlie Dickman <email@hidden> wrote:
>
>> 	int vmDataLength = 0;
>> 	do {
>> 		vmData = [vmRead availableData];
>> 		vmDataLength = [vmData length];
>> 	} while (vmDataLength != 0);
>
> Don't you mean "== 0" on the final line?
> Also, spin-loops like this are a really bad idea — this loop is going to consume something like 100% CPU. If you have to loop like this, run the current run loop in between tests.
>
> —Jens

Charlie Dickman
email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Using NSPipe to get system command output (From: Charlie Dickman <email@hidden>)
 >Re: Using NSPipe to get system command output (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Using NSPipe to get system command output
  • Next by Date: Re: Using NSPipe to get system command output
  • Previous by thread: Re: Using NSPipe to get system command output
  • Next by thread: Re: Using NSPipe to get system command output
  • Index(es):
    • Date
    • Thread