Re: Pseudo-terminals and NSTask
Re: Pseudo-terminals and NSTask
- Subject: Re: Pseudo-terminals and NSTask
- From: Chuck Norris <email@hidden>
- Date: Sun, 16 Dec 2001 15:19:08 -0800
Andrew - thanks for the feedback. I tried something along these
lines originally, but ran into problems. I now understand ptys much
better and I'll give it another go. Knowing that it works for you is
very helpful.
Thanks!
Chuck
At 5:15 PM -0500 12/16/01, Andrew Mortensen wrote:
I recently had the same problem, and ultimately resorted to using straight
C to resolve it. The GNUStep version of NSTask has a usePseudoTerminal
method that is not, unfortunately, part of OS X or OpenStep. You could
look over the source for GNUStep's NSTask, but it's a little confusing
because they have to account for a number of different platforms, none of
which handle acquiring a pty in the same manner.
I used openpty ( 3 ) to get the pty and tty, and then forked, ultimately
launching the command line program in the child with execve. I then
communicate with the child process through the master end of the terminal
returned by openpty, with read and write. Very low level. I'm not sure
there's a good way to handle this with Apple's NSTask, at the moment. If
they ever add a userPseudoTerminal to the OS X implementation of NSTask,
it might be feasible; but thus far I've not seen any successful NSTask
programs that demand interactive input. I believe, judging by the results
of my tests, that Apple's NSTask does something that prevents ptys from
working properly. Obviously someone at Apple is better able to answer this
than I am.
Use select ( 2 ) and the FD macros to get the information from the child
process. Searches on groups.google.com helped me some in this regard.
Good luck.
andrew
Envoy: love me, love my umbrella.
-james joyce
On Sun, 16 Dec 2001, Chuck Norris wrote:
I need to be able to run a program from within a pty to get a
complete terminal environment that some programs require (line
discipline, curses support, stty-like stuff in general).
I've been using NSTask up to now, and was hoping to come up with some
way to get pty support from within the Cocoa infrastructure. But the
only references to that sort of thing that I've found are within the
GNUStep code. I'm willing to dig into that to figure it out, but I'm
curious what other people have done.
I've been experimenting with stock BSD pty code, but even that is
giving me fits. The example code from Stevens (Advanced Programming
in the UNIX Environment) doesn't even work, so either something's
pretty badly broken, or there is something unique to OSX that I'm
omitting. I've read rumors of pty "troubles" under Mac OS X, but
since other programs that obviously use ptys are working fine, I
presume there's just something I'm not doing right.
Anyone with some insight to get me going in the right direction?
Regards,
Chuck
_______________________________________________
MacOSX-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/macosx-dev