Is PTY's slave side open?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Is PTY's slave side open?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Is PTY's slave side open?  
Gerhard Rieger


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-28-04 12:48 PM

Hi,

I am developing a GPL'ed utility (http://www.dest-unreach.org/socat/)
that creates a PTY and holds its master side. When another process opens
the slave side, the utility transfers data between the PTY and some
other bidirectional channel.

My problem is that the utility can generally not determine if the PTY's
slave side is in use and data transfer should start. This can block
resources on the other channel (German readers, check out Heise c't
2004/13, p.200), or, even worse, result in a permanent error when the
utility writes to the PTY's master side before the slave side is opened
(e.g. on Solaris).

On some of the platforms that implement the non-standard openpty()
mechanism instead of /dev/ptmx, this problem can be handled with polling
the HUP status of the PTY using poll(): The code opens the slave side
and closes it immediately, causing a HUP condition. It then polls the
HUP condition of the PTY in regular intervalls. When the HUP condition
ends, this indicates that the slave side has been opened. But this is
ugly and not generally usable.

Any ideas?

Gerhard Rieger <rieger@dest-unreach.org>





[ Post a follow-up to this message ]



    Re: Is PTY's slave side open?  
Antoine Mathys


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-28-04 10:49 PM

> My problem is that the utility can generally not determine if the PTY's
> slave side is in use and data transfer should start. This can block
> resources on the other channel (German readers, check out Heise c't
> 2004/13, p.200), or, even worse, result in a permanent error when the
> utility writes to the PTY's master side before the slave side is opened
> (e.g. on Solaris).

Have you tried to set O_ASYNC on the master side? it should gives you a
SIGIO whenever input or output is possible.

Antoine Mathys





[ Post a follow-up to this message ]



    Re: Is PTY's slave side open?  
Gerhard Rieger


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-29-04 07:48 AM

I don't think that sigio does much different from the status that
select() gives, and that indicates immediately "ready for writing".


Antoine Mathys wrote: 
>
>
> Have you tried to set O_ASYNC on the master side? it should gives you a
> SIGIO whenever input or output is possible.
>
> Antoine Mathys





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:16 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register