Fatal bug in select

Hi,

it seems not to be possible to check the readabilty of a file with
select. The select call always locks up and gets a timedout even if
the file has been opened in RD_ONLY mode.

There must be a BUG … here is the test routine:

Armin

#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>


int main( void )
{
int console, serial;
struct timeval tv;
fd_set rfd;
int n;

if( ( console = open( “/g.bin”, O_RDONLY ) ) == -1)
{
perror( “open” );
return EXIT_FAILURE;
}

/*

  • Clear the set of read file descriptors, and
  • add the two we just got from the open calls.
    */
    FD_ZERO( &rfd );
    FD_SET( console, &rfd );

/*

  • Set a 5 second timeout.
    */
    tv.tv_sec = 5;
    tv.tv_usec = 0;

switch ( n = select( 1 +console, &rfd, 0, 0, &tv ) ) {
case -1:
perror( “select” );
return EXIT_FAILURE;
case 0:
puts( “select timed out” );
break;
default:
printf( “%d descriptors ready …\n”, n );
if( FD_ISSET( console, &rfd ) )
puts( " – console descriptor has data pending" );
}
return EXIT_SUCCESS;
}

Armin Steinhoff <a-steinhoff@web_.de> wrote:

it seems not to be possible to check the readabilty of a file with
select. The select call always locks up and gets a timedout even if
the file has been opened in RD_ONLY mode.

Assuming that your “/g.bin” is hosted on a devb-* filesystem …

A change in some of the internal implementation bits/masks for
select() wasn’t updated in devb-*, resulting in this behaviour.
This is internal PR/8931, and has been fixed for 6.1.1; select()
will return immediately on any involvement of a disk-based file.

John Garvey wrote:

Armin Steinhoff <a-steinhoff@web_.de> wrote:
it seems not to be possible to check the readabilty of a file with
select. The select call always locks up and gets a timedout even if
the file has been opened in RD_ONLY mode.

Assuming that your “/g.bin” is hosted on a devb-* filesystem …

Yes … it is hosted on a devb-* filesystem.

A change in some of the internal implementation bits/masks for
select() wasn’t updated in devb-*, resulting in this behaviour.
This is internal PR/8931, and has been fixed for 6.1.1; select()
will return immediately on any involvement of a disk-based file.

Hope this will also happen with the write direction.
Is there a release date for 6.1.1 ?

Thanks

Armin

Hi John,

has rdchk() the same problem ??

Armin

Armin Steinhoff wrote:

John Garvey wrote:

Armin Steinhoff <a-steinhoff@web_.de> wrote:
it seems not to be possible to check the readabilty of a file with
select. The select call always locks up and gets a timedout even if
the file has been opened in RD_ONLY mode.

Assuming that your “/g.bin” is hosted on a devb-* filesystem …

Yes … it is hosted on a devb-* filesystem.

A change in some of the internal implementation bits/masks for
select() wasn’t updated in devb-*, resulting in this behaviour.
This is internal PR/8931, and has been fixed for 6.1.1; select()
will return immediately on any involvement of a disk-based file.

Hope this will also happen with the write direction.
Is there a release date for 6.1.1 ?

Thanks

Armin