This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re[2]: ioctl(), TIOCSWINSZ and pseudo terminal slaves


CV> On Mon, Jun 17, 2002 at 01:21:58PM +0200, Pavel Tsekov wrote:
>> This is just a heads up message :)
>> 
>> The above combination doesn't succeed (-1 is returned), but the errno
>> is not set approapriately.

CV> What's the expected errno?

My report wasn't quite right for which I apologize. errno is not set,
so its value is 0 (No error). I don't know which the correct value for
errno is in this case though :(

However I investiagted a bit more... From the source I can see that
this ioctl () function seems to be not implemented for pty slaves
when the master is opened with fhandler_pty_master::open() method -
I refer to this comment from fhander_tty.cc, line 461:

  /* output_done_event may or may not exist.  It will exist if the tty
     was opened by fhandler_tty_master::init, normally called at
     startup if use_tty is non-zero.  It will not exist if this is a
     pty opened by fhandler_pty_master::open.  In the former case, tty
     output is handled by a separate thread which controls output.  */

and some lines below this one (line 489):

  /* The ioctl events may or may not exist.  See output_done_event,
     above.  */

Now in this case (pty's) the following code from line 976

      get_ttyp ()->ioctl_retval = -1;
      get_ttyp ()->arg.winsize = * (struct winsize *) arg;
      if (ioctl_request_event) // This will be NULL
    SetEvent (ioctl_request_event);
      if (ioctl_done_event) // and this also
    WaitForSingleObject (ioctl_done_event, INFINITE);
      break;

will cause the return value of the ioctl() to be -1 but doesn't
set errno.

I see two possible solutions for this problem, though I don't have the insights to
decide which one is correct (of course maybe there are others):

1. The ioctl* events should not be handled like the read/write events
i.e. maybe they need to be created both for TTY masters and PTY
masters in tty::common_init().

2. Check in fhandler_tty_slave::ioctl() if the master is a PTY and set
ENOSYS for TIOCSWINSZ function.

I have to note that my knowledge on PTYs is not good at all and I
can't forsee other solutions without further information. I noted this
problem in my effort to port Midnight Commander to cygwin.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]