Help! pty's, read(), and EINVAL

Help! pty's, read(), and EINVAL

Post by Michael P. Moss » Thu, 13 Oct 1994 03:04:21

I'm developing a program that execs ftp as a child process, and in
order to eliminate standard I/O buffering, I had to use a
pseudo-terminal.  Being new to the unix world, but not to C, I plowed
ahead and found a source listing in Stevens' book _Adv. Prog. in Unix_
for pty's.  I used it, and it seemed to work nicely for my purpose :
send commands to ftp and parse its responses to ensure that the
command executes properly.

During development, I ran into a snag, though, that really has me
stumped: about 15% of the time, and on an intermittent basis, the
read() from the file descriptor that's been mapped to ftp's I/O fails
with errno EINVAL.  The man page says " Attempted to read from a
stream linked  to  a multiplexor.".  Understand that this occurs after
select() told me that something is available for reading on that same

I've purify'd, I've truss'd, I've dbx'd.  Nothing makes it behave any
better, and there are no obvious clues as to what the error message
really means.  Of course, sounds like a plain-old pointer bug to me,
but I'd still like to see if anyone's got an idea.

Oh, yes, I'm running Solaris 2.3 on a Sparc 10/512.

Got any ideas ?  This problem is making me lose sleep.  Please e-mail
me if you've got something that may be of help.  Thanks.


David Freda


I'm posting this for Dave.  You can send replies to me or to Dave.


Mike Mossey               "Give any one idea a push and it falls down
                           easily.  The pusher, and the pushed, are then
                           engaged in that entertainment called a discussion."
                               -my best recollection of a John Cage quote