in reply to Expect can't assign a pseudo-tty

Run the test script in the debugger and set a break point line 159 of IO::File.

Looking at that file, it seems that the caller to IO::File->open() with an undefined value. Taking a guess, I'd think that the caller tries to look up the name of the next available pseudo TTY to use, fails, doesn't notice the failure, and then tries to open undef.

But by using the debugger you can determine what is the real problem and then rerun the test with a break point earlier (and in the caller) and probably figure out why.

        - tye (but my friends call me "Tye")
  • Comment on (tye)Re: Expect can't assign a pseudo-tty

Replies are listed 'Best First'.
Re: (tye)Re: Expect can't assign a pseudo-tty
by khippy (Scribe) on Jun 25, 2001 at 14:48 UTC
    Hi tye,
    thank your for your quick answer. I had to take time to
    come to know the debugger, and here is the result:

    ---cut-here---
    ~/.cpan/build/IO-Tty-0.04# perl -d try
    Default die handler restored.

    Loading DB routines from perl5db.pl version 1.07
    Editor support available.

    Enter h or `h h' for help, or `man perldebug' for more
    help.

    Using /root/.cpan/build/IO-Tty-0.04/blib
    main::(try:5): require POSIX;
    DB<1> f /usr/local/lib/perl5/5.6.1/i686-linux/IO/File.pm
    1 #
    2
    3 package IO::File;
    4
    5 =head1 NAME
    6 7 8 9 10
    DB<2> b 159
    DB<3> f try
    1 #!/usr/local/bin/perl -w
    2
    3: use blib;
    4: use IO::Pty;
    5==> require POSIX;
    6
    7
    8: $pty = new IO::Pty;
    9
    10: unless (@ARGV)
    DB<4> n
    POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:3):
    3: our(@ISA, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD) = ( );
    DB<4> n
    POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:9):
    9: our $VERSION = "1.03" ;
    DB<4>n
    POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:12):
    12: my $loaded;
    DB<4> n
    POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:24):
    24: XSLoader::load 'POSIX', $VERSION;
    DB<4> n
    POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:26):
    26: my $EINVAL = constant("EINVAL", 0);
    DB<4> n
    POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:27):
    27: my $EAGAIN = constant("EAGAIN", 0);
    DB<4> n
    POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:80):

    80: 1;
    81: __END__
    DB<4> n
    main::(try:8): $pty = new IO::Pty;
    DB<4> n
    main::(try:10): unless (@ARGV)
    main::(try:11): {
    DB<4>n
    main::(try:12): my $slave = $pty->slave;
    DB<4> n
    IO::File::open(/usr/local/lib/perl5/5.6.1/i686-linux/IO/File.pm:159):
    159: return sysopen($fh, $file, $mode, $perms);
    DB<4> print $fh
    IO::Tty=GLOB(0x846bf5c)
    DB<5> print $file
    Use of uninitialized value in print at (eval 18)[/usr/local/lib/perl5/5.6.1/perl5db.pl:1521]line 2.

    DB<6> print $mode
    2
    DB<7> print $perms
    438
    DB<8>
    ---cut-ends---

    As we can see, $file is undef, so you are right with
    your assumption. I also tried the code from
    SYNOPSIS of the IO::Pty documentation and there is
    the same error, it has an undef filename.

    Now I know *what* is wrong, but I still don't know
    *why*.

    Is there a module experienced helper out there ???

    thanx so far

    there are no silly questions
    killerhippy

      You need to change that "b 159" to instead set a break point near the top of that routine so you can see how $file is being set and then investigate that further.

              - tye (but my friends call me "Tye")