jhill03 has asked for the wisdom of the Perl Monks concerning the following question:

Hallowed Monks,

I have a process in place that creates child processes, each of which create their own Expect object. For some children, the following error is returned upon instantiation of the Expect object:
Cannot create a new IO::Tty from fd -1: Invalid argument

The error seems to happen after X number of children are spawned. If I do say 50 children, it works fine. 90... not so much.
Also, this seems to be happening only on one box. It does not happen on another box that is configured the same way.
I am running on HP-UX 11.11 on both boxes, and the nstrpty and npty are both set to 512.
So I'm not sure why I'm getting -1 returned...

Since Expect.pm uses IO::Pty to instantiate the psuedo tty, I drilled down and found this call:
my ($ptyfd, $ttyfd, $ttyname) = pty_allocate();

However, I can't really find any information on this method to try and decipher why it is returning -1 into $ttyfd (thus causing the error). I do see that the nstrtel is set to 60, however it is that way on both boxes (the one that works and the one that doesn't) so I don't think that's it either. Besides, I believe that parameter controls incoming telnet sessions, and I'm dealing with outgoing sessions here...

I'm hoping someone may have knowledge of IO::Pty and/or pty_allocate() and can point me in the direction of what to check that may be causing this error. I checked the documentation on CPAN for this module, but it really didn't have anything. My basic impression is that pty_allocate() is *expected* to be able to create an fd on pty and tty.

Any help would be greatly appreciated.

System Info
O/S: HP-UX B.11.11
perl: 5.6.1

Thanks,

Jayson

Replies are listed 'Best First'.
Re: Error when creating Expect object
by almut (Canon) on Dec 10, 2008 at 23:57 UTC

    Are you sure the respective number of device files have actually been created? (ls /dev/ptym/* |wc) — the default seems to be 60.  With which exact parameters did you run insf(1M)?