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

Using NSPipe to get system command output


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

I'm trying to get the output from a vm_stat command using the following code. My app hangs in the [vmRead availableData] call as it should if there is no data available but it never comes back. What am I doing wrong? I have searched through the sample code on apples developer site with no luck.

	NSPipe *vmPipe = [NSPipe pipe];
	NSFileHandle *vmRead = [vmPipe fileHandleForReading];

	[vm setLaunchPath: @"/usr/bin/vm_stat"];	//	1 page = 4096 bytes
	[vm setStandardOutput: vmPipe];
	[vm launch];
	NSData *vmData = nil;
	int vmDataLength = 0;
	do {
		vmData = [vmRead availableData];
		vmDataLength = [vmData length];
	} while (vmDataLength != 0);

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

  • Follow-Ups:
    • Re: Using NSPipe to get system command output
      • From: Kyle Sluder <email@hidden>
    • Re: Using NSPipe to get system command output
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: NSCopyObject is a disaster (was Re: Another NSOutlineView issue)
  • Next by Date: Re: NSCopyObject is a disaster (was Re: Another NSOutlineView issue)
  • Previous by thread: PackageMaker Unable to Change Content Permission
  • Next by thread: Re: Using NSPipe to get system command output
  • Index(es):
    • Date
    • Thread