Can I use SysV IPC at the same time as select or poll?

Can I use SysV IPC at the same time as select or poll?


No. (Except on AIX, which has an incredibly ugly kluge to allow
this.)



In general, trying to combine the use of select() or
poll() with using SysV message queues is troublesome. SysV IPC
objects are not handled by file descriptors, so they can't be passed to
select() or poll(). There are a number of workarounds, of
varying degrees of ugliness:






  • Abandon SysV IPC completely. :-)



  • fork(), and have the child process handle the SysV IPC,
    communicating with the parent process by a pipe or socket, which the
    parent process can select() on.



  • As above, but have the child process do the select(), and
    communicate with the parent by message queue.



  • Arrange for the process that sends messages to you to send a signal
    after each message. Warning: handling this right is
    non-trivial; it's very easy to write code that can potentially lose
    messages or deadlock using this method.



(Other methods exist.)






Home FAQ