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 ]
|