select_attach question 2

so i checked out the driver code, and the default io_notify() function is
being used. i also tried running the sample code that use select_attach()
from the library files for dispatch_create() at

when i run the sample code using two text files i get the same output as
that described below. the program goes into the dispatch loop, starts
executing dispatch_block, and then exits the program returning 0 without
printing any error messages or calling any callback functions. The
description of my code is below:

when i run the loop:

printf("here\n ");
ctp_ret = dispatch_block(ctp);
printf(“dispatch handler\n”);
} else {
fprintf(stderr, “dispatch_block: failure\n”);
printf(“closing server\n”);

i get the following output:
the line “here” is printed
and then the program terminates, returning the value 0 without printing
anything else.

any ideas?

“David Gibbs” <> wrote in message

sutin chen <>> > wrote:
a question about select_attach:

so i am using a device driver for a CAN bus, and i want to execute a
callback function everytime a message arrives on the CAN bus.

the CAN driver works by using a file descriptor. to read a message you
read from the file descriptor using read().


correct me if i’m wrong, but i should be able to use select_attach() on
file descriptor and it should call a function everytime there is a
waiting to be read, right? as of the moment, the callback function is

That depends.

Who wrote the CAN bus resource manager, and did they implement the
underlying support to make select() work?

select(), select_attach(), and io_notify() all use the _IO_NOTIFY
message, and if the resource manager for the CAN bus doesn’t handle
_IO_NOTIFY, then you will never unblock in your select_attach handler.

(You might want to make sure you’re using select_attach() properly
by testing against a resource manager where you know it is
implemented, e.g. a serial port, TCP/IP socket, or pseudo-tty.)


QNX Training Services
Please followup in this newsgroup if you have further questions.