Mixing handles in select() in QNX6.3

I want to use select() to block on a variety of handles for reading from
devices.

It blocks on handles with mq_open, but does not want to block on
attach->chid. I am using name_attach() to create a channel. It then blocks
on MsgReceive as there is no data to receive.

Can one use select() to block on a channel id?

I also found that if I use a timeout on select(), select unblocks correctly
before the first timeout occur if there is data ready. But once a timeout
occur, select() only unblocks on a timeout and not on incoming data. I reset
timeout before calling reset.

Francois

Francois Joubert <francois@truvelo.co.za> wrote:

I want to use select() to block on a variety of handles for reading from
devices.

It blocks on handles with mq_open, but does not want to block on
attach->chid. I am using name_attach() to create a channel. It then blocks
on MsgReceive as there is no data to receive.

Can one use select() to block on a channel id?

No.

But, you can use ionotify() for all the fds you were using for select()
to send you a pulse when you would have been unblocked from select(),
and then use MsgReceive() to block on the chid, and handle both types
of incoming messages that way.

I also found that if I use a timeout on select(), select unblocks correctly
before the first timeout occur if there is data ready. But once a timeout
occur, select() only unblocks on a timeout and not on incoming data. I reset
timeout before calling reset.

Do you reset your fd arrays properly? On timeout, I’d expect them to
all be zero (I think). If you don’t rearm them, you’ll just wait for
the timeout.

And, for the MsgReceive() choice – you can timeout your message receive
with TimerTimeout(), or setup a system timer (timer_create(), etc) to
deliver a regular pulse if you need to do something on a regular basis.

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:cmdh5b$bqb$1@inn.qnx.com

Francois Joubert <> francois@truvelo.co.za> > wrote:
I want to use select() to block on a variety of handles for reading from
devices.

It blocks on handles with mq_open, but does not want to block on
attach->chid. I am using name_attach() to create a channel. It then
blocks
on MsgReceive as there is no data to receive.

Can one use select() to block on a channel id?

No.

But, you can use ionotify() for all the fds you were using for select()
to send you a pulse when you would have been unblocked from select(),
and then use MsgReceive() to block on the chid, and handle both types
of incoming messages that way.

I also found that if I use a timeout on select(), select unblocks
correctly
before the first timeout occur if there is data ready. But once a timeout
occur, select() only unblocks on a timeout and not on incoming data. I
reset
timeout before calling reset.

Do you reset your fd arrays properly? On timeout, I’d expect them to
all be zero (I think). If you don’t rearm them, you’ll just wait for
the timeout.

This is where my problem is. Thank you.

And, for the MsgReceive() choice – you can timeout your message receive
with TimerTimeout(), or setup a system timer (timer_create(), etc) to
deliver a regular pulse if you need to do something on a regular basis.

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com