develooper Front page | perl.perl5.porters | Postings from July 2001

[ID 20010723.011] IO::Pty objects and the -t operator

Hans Ecke
July 23, 2001 18:54
[ID 20010723.011] IO::Pty objects and the -t operator
Message ID:

This is a bug report for perl from,
generated with the help of perlbug 1.28 running under perl v5.6.0.


Hi List,

this mail tries to report a bug with the IO::Pty module on SunOS.
I first noticed this bug last year trying to use the Expect module
which breaks due to it.

When I notified Roland Giersig (, the current
maintainer, he said its not really a bug. I disagree. I never really
followed up on this due to personal upheavals. Now I'm again working
with Expect and again it dies on SunOS.

Following is my original bugreport (slightly edited). If the list agrees 
with Roland that its not a bug, please explain why. If you guys think 
this is a real bug, do you have any idea how to fix it?

I omit Rolands original reply because he wrote that privately and might 
object in having it public. I also didn't really understand it :-)

************ begin original bugreport **************

Please consider the following minimal perl program:

perl -MIO::Pty -e'$T=new IO::Pty;print ${*$T}{'io_pty_ttyname'};if(-t
$T){print " is a tty\n";}else{print " is no tty\n";}'

You would expect it to print "xxx is a tty" in _any_ case. In fact, it
does not.

IRIX64 6.5            : /dev/ttyq8 is a tty
SunOS 5.6             : /dev/pts/11 is no tty
Linux 2.2 (Redhat 7.0): /dev/pts/1 is a tty
AIX 4.3               : /dev/pts/3 is a tty

All of them are Perl 5.6 with current IO::Pty.

Tty.xs seems to have to wade through pretty thick muck to implement
OpenPTY (which is called by IO::Pty::new()). I guess something in there
goes wrong.

************* end original bugreport ********************

This might be good or bad, the problem is that this behavior breaks An Expect object inherits from IO::Pty. The function 
Expect::exp_stty() calls both POSIX::isatty() (which fails because its 
identical to -t) and IO::Stty::stty(). IO::Stty::stty() calls isatty() 
and a lot of terminal related stuff I don't really understand. Anyhow
the first isatty() will kill Expect::exp_stty().

This is the reason I believe this is a bug: It breaks the Expect module.

If you think this too, please write where to start digging for a solution.
We need it working for an in-company program and could spend some
(not too much) manpower on fixing this.

Please CC: Chris Jones ( as he is the co-developer.

Thank you very much

    Hans Ecke (

Site configuration information for perl v5.6.0:

Configured by crs at Tue Nov 28 19:01:02 MST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
    osname=solaris, osvers=2.8, archname=sun4-solaris
    uname='sunos lager 5.8 generic sun4u sparc sunw,ultra-80 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
    cc='cc', optimize='-O', gccversion=
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/opt/SUNWspro/WS6/lib '
    libpth=/opt/SUNWspro/WS6/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt -lsec
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G -L/opt/SUNWspro/WS6/lib'

Locally applied patches:

@INC for perl v5.6.0:

Environment for perl v5.6.0:
    LANG (unset)
    LANGUAGE (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About