• 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: NSTask troubles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask troubles


  • Subject: Re: NSTask troubles
  • From: John Stiles <email@hidden>
  • Date: Thu, 12 Jul 2007 18:01:41 -0700


On Jul 12, 2007, at 4:45 PM, Alastair Houghton wrote:

On 13 Jul 2007, at 00:38, John Stiles wrote:

On Jul 12, 2007, at 4:29 PM, John Stiles wrote:

On Jul 12, 2007, at 4:16 PM, Alastair Houghton wrote:

2. Change your program to use a pseudo-tty rather than a pipe.

or option 2, this is unfamiliar territory for me, so do you know where I could find any sort of example code? (I'll Google around as well)

Is openpty() what I'm looking for here?

Yes, either that or posix_openpt().

Well, I got this far but it's not working at all.

@interface NSTask (PseudoTTY)
- (void) usePseudoTTY;
@end

@implementation NSTask (PseudoTTY)

- (void) usePseudoTTY
{
int masterFD, slaveFD;
if( 0 != openpty( &masterFD, &slaveFD, NULL, NULL, NULL ) )
{
ASSERT( !"unable to start pseudo-tty" );
return;
}

[self setStandardInput:[[[NSFileHandle alloc] initWithFileDescriptor:slaveFD] autorelease]];
[self setStandardOutput:[[[NSFileHandle alloc] initWithFileDescriptor:masterFD] autorelease]];
}


@end

NS_DURING
[atosTask setLaunchPath:@"/usr/bin/atos"];
[atosTask setArguments:[NSArray arrayWithObjects:
@"-o",
[[NSFileManager defaultManager] stringWithFileSystemRepresentation:imagePath strlen(imagePath)],
NULL]];
[atosTask usePseudoTTY];
[atosTask launch];
NS_HANDLER
// fail gracefully
return;
NS_ENDHANDLER



I'm getting back the string I write in, with one change—'\n' gets converted to '\r\n'.
I tried switching around the slave and master but that didn't work either.


_______________________________________________

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: NSTask troubles
      • From: John Stiles <email@hidden>
References: 
 >NSTask troubles (From: John Stiles <email@hidden>)
 >Re: NSTask troubles (From: Alastair Houghton <email@hidden>)
 >Re: NSTask troubles (From: John Stiles <email@hidden>)
 >Re: NSTask troubles (From: Alastair Houghton <email@hidden>)
 >Re: NSTask troubles (From: John Stiles <email@hidden>)
 >Re: NSTask troubles (From: John Stiles <email@hidden>)
 >Re: NSTask troubles (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: NSTask troubles
  • Next by Date: setAutohidesScrollers notification
  • Previous by thread: Re: NSTask troubles
  • Next by thread: Re: NSTask troubles
  • Index(es):
    • Date
    • Thread