Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tcl8.3.1: bug or feature ? in open/fconfigure

3 views
Skip to first unread message

Paul Duffin

unread,
Jun 13, 2000, 3:00:00 AM6/13/00
to
Uwe Klein wrote:
>
> Dave LeBlanc wrote:
> >
> > I went by the fconfigure man page for tcl8.3.1 which does not mention
> > a mode option. Perhaps you where somehow falling through to using the
> > OS fconfigure instead of tcl's fconfigure... OR, the help files are
> > out of date... not unheard of.
>
> Dear Sir,
> you have not understood up to now that this fconfigure option works on
> tty's ( really! ). what i was hinting at is that "open" should produce
> an
> error in this circumstance.
>
> have a look at "man n open"
> about line 139
>
> SERIAL COMMUNICATIONS
> If fileName refers to a serial port, then the specified |
> serial port is opened and initialized in a platform-depen­ |
> dent manner. Acceptable values for the fileName to use to |
> open a serial port are described in the PORTABILITY ISSUES |
> section. |
>

From the portability issues section.

Unix
Valid values for fileName to open a serial port are generally
of the form /dev/ttyX, where X is a or b, but the name of any
pseudo-file that maps to a serial port may be used.

The way it actually determines whether it is a serial port is use
the isatty (fd) function. I presume that this returns FALSE on those
devices for which there a device special file but no hardware and so Tcl
assumes that it is not a TTY and so does not do any special processing.

If Tcl gets an error from opening a file then it returns it, otherwise
it can't. So it appears as though the device driver for those
/dev/ttyS<x> special files allows the file to be opened even when there
is no hardware.

You should use the fact that it is not a TTY and therefore does not
have the serial port options as an indicator that it does not have
any hardware. Add a [catch] around an [fconfigure $channel -mode]
to detect whether it is a valid TTY or not.

Uwe Klein

unread,
Jun 13, 2000, 3:00:00 AM6/13/00
to
Paul Duffin wrote:
> You should use the fact that it is not a TTY and therefore does not
> have the serial port options as an indicator that it does not have
> any hardware. Add a [catch] around an [fconfigure $channel -mode]
> to detect whether it is a valid TTY or not.
Hi,
Thanks for your reply.

this would be a possibilty.

I had a look into tclUnixChan.c and did some experimenting.
isatty() returns 0 on any error ( it does not look at errno ).
would it be apropriate to check for ENOTTY / EIO after the call to
isatty()
and close the file on EIO?

i've submitted a patch in this direction.

G!
UK
--
Uwe Klein [mailto:uwe-...@foni.net]
KLEIN MESSGERAETE Habertwedt 1
D-24376 Groedersby b. Kappeln, GERMANY
phone: +49 4642 920 123 FAX: +49 4642 920 125

Paul Duffin

unread,
Jun 19, 2000, 3:00:00 AM6/19/00
to
Uwe Klein wrote:
>
> Paul Duffin wrote:
> > You should use the fact that it is not a TTY and therefore does not
> > have the serial port options as an indicator that it does not have
> > any hardware. Add a [catch] around an [fconfigure $channel -mode]
> > to detect whether it is a valid TTY or not.
> Hi,
> Thanks for your reply.
>
> this would be a possibilty.
>
> I had a look into tclUnixChan.c and did some experimenting.
> isatty() returns 0 on any error ( it does not look at errno ).
> would it be apropriate to check for ENOTTY / EIO after the call to
> isatty()
> and close the file on EIO?
>
> i've submitted a patch in this direction.
>

I just had a look on AIX documentation and the only error codes that are
returned by isatty are ENOTTY and EBADF. Under what circumstances does
isatty return EIO ? What OS are you running on ?

0 new messages