[comp.unix.questions] wait on ipc message

pgd@bbt.se (12/09/90)

I want to stall a process, to wake up on a message received
through a SYSV ipc message, or data available on any file.
That is, i want a select/poll to also include messages received
through an ipc channel.

Is this possible, somehow?

No sockets, no streams, no multiple processes solutions.

What I want to do is to simulate sockets with ipc messages.
 
(My os is Xenix/386)

rawdon@rex.cs.tulane.edu (Michael Rawdon) (12/10/90)

In <1990Dec9.091203.4188@bbt.se> pgd@bbt.se writes:
>I want to stall a process, to wake up on a message received
>through a SYSV ipc message, or data available on any file.
>That is, i want a select/poll to also include messages received
>through an ipc channel.

If I understand what you're asking correctly, I believe if you have the
following command format for receiving a message:

msgrcv (msqid, msgp, msgsz, msgtyp, msgflg)

then if you simply do *not* set IPC_NOWAIT in msgflg, the process will
block until a message of type 'msgtyp' appears on the message queue with
id 'msqid'.  'msqid' is an int and 'msgtyp' is a long.  'msgflg' is an int
also, actually, but INC_NOWAIT is predefined in one of the relevant header
files.

I got this info from IBM's AIX manuals, but the functionality was identical
(or nearly so, enough so that I don't recall having any problems with it)
on our Pyramid 9815 running System V.

-- 
			     Michael Rawdon
		Tulane University, New Orleans, Louisiana
------------------------------------------------------------------------------
Internet: rawdon@rex.cs.tulane.edu | Knowledge may be power, but 
Usenet: rex!rawdon.uucp            | withholding knowledge can be a 
Bitnet: CS6FECU@TCSVM              | dangerous thing.
-----------------------------------------------------------------------------
Disclaimer: Opinions mine, typos and grammar errors someone else's.

pgd@bbt.se (12/10/90)

In article <5335@rex.cs.tulane.edu> rawdon@rex.cs.tulane.edu (Michael Rawdon) writes:
>In <1990Dec9.091203.4188@bbt.se> pgd@bbt.se writes:
>>I want to stall a process, to wake up on a message received
>>through a SYSV ipc message, or data available on any file.
>>That is, i want a select/poll to also include messages received
>>through an ipc channel.
>
>If I understand what you're asking correctly, I believe if you have the
>following command format for receiving a message:
>
>msgrcv (msqid, msgp, msgsz, msgtyp, msgflg)
>
>then if you simply do *not* set IPC_NOWAIT in msgflg, the process will
>block until a message of type 'msgtyp' appears on the message queue with
>id 'msqid'. 

Yes, but i want the process to wake up on input from a selected normal
file also. (Which in this case means the keyboard or a serial port).
One way of doing it is to have a separate process reading the
keyboard, send an ipc message to wake up the main process. But to
avoid the extra overhead, I want to do both things in the same
process.

The os Xenix/386 has the poll() system call, but I have no manual page
for poll. In the signal.h system file I find the SIGPOLL signal. Is it
possible to make a poll() interrupt with SIGPOLL? Then the problem
could be solved by issuing an interrupting poll(), and then a
msgrcv().  If a message is coming in, the msgrcv() returns ok, if a
poll is satisfied, the msgrcv() would return EINTR, and a character is
available on one of the files (which could be checked out with another
poll()).