[comp.windows.x] unix System V

velayos@bosco.dit.upm.es (M. del Mar Palazuelos) (06/01/89)

We are working with Compac 386 using X-window version 11 release III and unix
system V of Interactive. 
When we use AtAddInput over a pipe there is an error "select failed" with
"ERRNO  =  ENO TTY".
The select used is from libnet.a provided by X-windows, because in System V 
there  is not select instruction.
Can you help me?
		Thanks for all.
		please answer by mail.

tmb@ai.mit.edu (Thomas M. Breuel) (06/02/89)

   From: velayos@bosco.dit.upm.es (M. del Mar Palazuelos)
   Newsgroups: comp.windows.x
   Date: 1 Jun 89 10:48:53 GMT
   Reply-To: velayos@bosco.dit.upm.es (M. del Mar Palazuelos)
   Organization: Dept. Ingenieria de Sistemas Telematicos, dit, upm, Madrid, Spain


   We are working with Compac 386 using X-window version 11 release III and unix
   system V of Interactive. 
   When we use AtAddInput over a pipe there is an error "select failed" with
   "ERRNO  =  ENO TTY".
   The select used is from libnet.a provided by X-windows, because in System V 
   there  is not select instruction.
   Can you help me?

You lose. System V doesn't have a general way of implementing a
select() function that works on all possible kinds of file descriptors
(there is no "real" non-blocking I/O, i.e., something that would let
you distinguish EOF from no-data-available, and there is no general
way of finding out how much data is available on a file descriptor).
In fact, I would strongly recommend not using the select() function in
any Xlib provided for System V systems because you don't know what or
how much they did implement.

A hack to get around this problem is to do a read() on the file
descriptor you are interested in and use an alarm() call to time out
after a second if there is no data. The granularity isn't great, but
it works well enough if you don't do it on more than one or two file
descriptors.

bcarb@KSP.Unisys.COM (Brian Carb) (06/08/89)

>>   We are working with Compac 386 using X-window version 11
>>   release III and unix system V of Interactive. When we
>>   use AtAddInput over a pipe there is an error "select failed" with
>>   ...
>You lose. System V doesn't have a general way of implementing a
>select() function that works on all possible kinds of file descriptors
>(there is no "real" non-blocking I/O, i.e., something that would let
>you distinguish EOF from no-data-available, and there is no general
>way of finding out how much data is available on a file descriptor).
>..
>A hack to get around this problem is to do a read() on the file
>descriptor you are interested in and use an alarm() call to time out

We use the following code on a Unisys 6000/50 (Convergent) running
System V to check if data is available on a socket:

 /* Function to check if data exists on a TCP/IP socket */

  #include <sys/types.h>
  #include <sys/socket.h>
  
  int socketlisten(fd)
    int fd;
  {
    int chars_available;
    if(ioctl(fd,FIONREAD,(char *)&chars_available) < 0)
      return(-1);
    else
      return(chars_available);
  }

bcarb@ksp.unisys.com (Brian A. Carb)