Opening Pseudo Terminal

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.

Thanks in advance,
Joseph

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.

Thanks in advance,
Joseph

Joseph wrote:

How can I properly open and read the two ends of the pseudo terminal (eg
/dev/ptyp1 & /dev/ttyp1 ).

Use openpty().

Thank you for the clarification.

Does this mean that I cant do a read and write to the master terminal at the
same time?

Why is it possible at the slave end, and not in the master end?

Regards
Joseph

“Joe Mammone” <hw@qnx.com> wrote in message news:ekeuer$g5s$1@inn.qnx.com

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.

Thanks in advance,
Joseph

Thank you.

Will forkpty() also help? Can you share more ideas about when each is used?


Regards
Joseph

“Wojtek Lerch” <Wojtek_L@yahoo.ca> wrote in message
news:ekeuvn$ftf$1@inn.qnx.com

Joseph wrote:
How can I properly open and read the two ends of the pseudo terminal (eg
/dev/ptyp1 & /dev/ttyp1 ).

Use openpty().

Joseph wrote:

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.