why is there no poll/select like mechanism for message queue?

前端 未结 5 1958
感情败类
感情败类 2021-01-14 01:19

Like we can do, poll/epoll/select on an fd, we can not on msg queue id. I found some non standard methods to make msgqueue-id to fd, but afterall its a non standard. So my q

5条回答
  •  感情败类
    2021-01-14 02:16

    I'm surprised that it doesn't just work, but if it doesn't, I suspect the reason is to avoid encouraging such a non-portable practice. While message queue descriptors are allowed to be file descriptors, they're not required to be, and code that assumes they're file descriptors (and thus occupy the same "numberspace") is non-portable.

    If you need file descriptors, you'd probably be better off just using Unix sockets or some other mechanism in place of message queues. Message queues seem to be intended for use with real-time programming with threads where select/poll-based event-driven IO is generally not used.

提交回复
热议问题