OSF has nice things like openpty() and forkpty() but I cannot find similar
things in LINUX, although there is a
/dev/ptmx
However, I don't know how to use this.
Can anyone point me at a code example of how to allocate and use pty's under
LINUX? Or should I be using pts's and if so, how do I do this?
I'd be grateful for any pointers!
Alistair Windram
If anybody comes with a good answer, I will add it to the FAQ:
http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html#ptmx
I think I posted some example program once, but all I could
find was two lines of code.
--
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:aaa...@daimi.au.dk
or mailto:mcxumhv...@skrammel.yaboo.dk
[zaitcev@niphredil tmp]$ nm /usr/lib/libutil.a | grep openpty
openpty.o:
00000000 T openpty
U openpty
[zaitcev@niphredil tmp]$ cat /etc/redhat-release
Red Hat Linux release 7.3 (Valhalla)
[zaitcev@niphredil tmp]$
I source is pretty transparent, though I ever used it from a
JNI class. There's about 3..4 lines of example code in this:
http://people.redhat.com/zaitcev/java/jta20-p3-20001109.diff
-- Pete
/dev/ptmx is the master multiplexer for Unix98-style PTYs - the idea is
you open /dev/ptmx, use the TIOCGPTN ioctl on it to find the pseudo
terminal number, then open the slave device at /dev/pts/NNN where NNN is
that number.
On the other hand, if you #include <pty.h> then you get openpty and
forkpty. Probably that's the way to go for porting...
- Kevin.
> I have an app written for DEC UNIX (OSF) which uses PTY's and I am trying
> to port it to LINUX (initially Red Hat 7.2).
>
> OSF has nice things like openpty() and forkpty() but I cannot find similar
> things in LINUX, although there is a
> /dev/ptmx
> However, I don't know how to use this.
>
> Can anyone point me at a code example of how to allocate and use pty's
> under LINUX? Or should I be using pts's and if so, how do I do this?
>
Try 'info libc Pseudo-Terminals' on your Linux system,
on my Slackware 8.1 it shows code examples etc.
Ilja.
Many thanks to all who replied. I got pointers to code examples from Bob
Lynch, which do basic direct allocation of the /dev/ptyXX devices, and look
like they should work. However, I am fairly well convinced that I should use
openpty() and forkpty() by including <pty.h> (thanks, Kevin) (and I guess
that I have to specify -llibutil at link time - thanks Pete).
Alistair