How can I properly open and read the two ends of the pseudo terminal (eg
/dev/ptyp1 & /dev/ttyp1 ). Is there anything to be done before these can be
opened?
When I try to cat /dev/ptyp1, I cant do an echo to /dev/ptyp1.
But read and write to /dev/ttyp1 occurs without any problem simultaneously.
The ptypX entry is the master side of the pty. You can only have one
connection (open) to the master side of a pty at a time. The master side
of a pty can only be re-opened once the previous connection to the
master and all connections to its slave pair are closed.
Regards,
Joe
Joseph wrote:
How can I properly open and read the two ends of the pseudo terminal (eg
/dev/ptyp1 & /dev/ttyp1 ). Is there anything to be done before these can be
opened?
When I try to cat /dev/ptyp1, I cant do an echo to /dev/ptyp1.
But read and write to /dev/ttyp1 occurs without any problem simultaneously.
The ptypX entry is the master side of the pty. You can only have one
connection (open) to the master side of a pty at a time. The master side
of a pty can only be re-opened once the previous connection to the master
and all connections to its slave pair are closed.
Regards,
Joe
Joseph wrote:
How can I properly open and read the two ends of the pseudo terminal (eg
/dev/ptyp1 & /dev/ttyp1 ). Is there anything to be done before these can
be opened?
When I try to cat /dev/ptyp1, I cant do an echo to /dev/ptyp1.
But read and write to /dev/ttyp1 occurs without any problem
simultaneously.
Will forkpty() also help? Can you share more ideas about when each is used?
Like the documentation says, forkpty() combines openpty(), fork(), and
login_tty(). It’s a convenient way of saving several lines of code if a
fork() and a login_tty() is what you need to do after openpty(); but if
the next thing you’re going to do is exec(), then under QNX the spawn()
function is a more efficient way of doing what the fork(), login_tty(),
and exec() calls would do.