select_detach()

Detach a file descriptor from a dispatch handle

Synopsis:

#include <sys/iofunc.h>
#include <sys/dispatch.h>

int select_detach( void *dpp, 
                   int fd );

Arguments:

dpp
The dispatch handle, as returned by dispatch_create(), that you want to detach from the file descriptor.
fd
The file descriptor that you want to detach.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The function select_detach() detaches the file descriptor fd that was registered with dispatch dpp, using the select_attach() call.

Returns:

0
Success.
-1
The file descriptor fd wasn't registered with the dispatch dpp.

Examples:

#include <sys/dispatch.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

int my_func( … ) {
   …
}

int main( int argc, char **argv ) {
   dispatch_t           *dpp;
   int                  fd;
   select_attr_t        attr;


   if( ( dpp = dispatch_create() ) == NULL ) {
     fprintf( stderr, "%s: Unable to allocate \
              dispatch handle.\n",argv[0] );
     return EXIT_FAILURE;
   }

   if( argc ≤ 2 || ( fd = open( argv[1],
                    O_RDWR | O_NONBLOCK )) == -1 ) {
     exit(0);
   }
   
   select_attach( dpp, &attr, fd,
      SELECT_FLAG_READ | SELECT_FLAG_REARM, my_func, NULL );

   …

   if ( (select_detach( dpp, fd )) == -1 ) {
      fprintf( stderr, "Failed to detach \
               the file descriptor.\n" );
      return 1;
   }
}

For examples using the dispatch interface, see dispatch_create(), message_attach(), resmgr_attach(), and thread_pool_create().

Classification:

QNX Neutrino

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

select_attach(), select_query()