• 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
one NSPipe, multiple NSTasks?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

one NSPipe, multiple NSTasks?


  • Subject: one NSPipe, multiple NSTasks?
  • From: beamsplitter <email@hidden>
  • Date: Sun, 23 Mar 2003 23:41:22 -0500

I'd like to use one NSPipe instance for multiple successive NSTasks. I've tried this but can't get it to work:

NSPipe *myPipe = [[NSPipe alloc] init];
NSTask *myTask = [[[NSTask alloc] init] autorelease];
NSTask *myNextTask = [[[NSTask alloc] init] autorelease];

[myTask setStandardOutput: myPipe];
[myTask setStandardError: myPipe];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(getPipeOutput:) name: NSFileHandleReadCompletionNotification object: [myPipe fileHandleForReading]];
[[myPipe fileHandleForReading] readInBackgroundAndNotify];
[myTask launchTask];
// ...

// task has terminated
[[NSNotificationCenter defaultCenter] removeObserver: self name: NSFileHandleReadCompletionNotification object: [myPipe fileHandleForReading]];
// ...

[myNextTask setStandardOutput: myPipe];
[myNextTask setStandardError: myPipe];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(getPipeOutput:) name: NSFileHandleReadCompletionNotification object: [myPipe fileHandleForReading]];
[[myPipe fileHandleForReading] readInBackgroundAndNotify];
[myNextTask launchTask];
// ...etc

The second pair of setStandard methods cause an exception: "Exception raised during posting of notification. Ignored. exception: *** -[NSConcreteFileHandle fileDescriptor]: Bad file descriptor"

Can anyone point out my mistake?

Thanks,
Scott
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: one NSPipe, multiple NSTasks?
      • From: "John C. Randolph" <email@hidden>
    • Re: one NSPipe, multiple NSTasks?
      • From: Marcel Weiher <email@hidden>
  • Prev by Date: Re: nstoolbar and preferences
  • Next by Date: Distributed Objects, Threads, & graceful thread exits
  • Previous by thread: Re: Initial position of window
  • Next by thread: Re: one NSPipe, multiple NSTasks?
  • Index(es):
    • Date
    • Thread