signals interrupting IPC functions
Mike Maloney
mike at ISIDAPS5.UUCP
Fri Sep 23 06:44:26 AEST 1988
When a call to msgrcv terminates because of the arrival of a signal,
is it possible that a message on the queue could be lost? I want
to be able to read a message queue and process messages as soon as
they arrive, or timeout and do other stuff after 3 seconds:
signal(SIG_ALARM, timeout);
alarm(3);
s = msgrcv(id, buf, size, 0, 0);
if (s == -1)
{ if (errno == EINTR)
Timeout happened....do stuff.
else
Some other dasterdly error occurred.
}
else /* Timeout did not occur. */
{ alarm(0); /* Cancel alarm. */
...process message that arrived.
}
The code for the 'timeout' function does absolutely nothing. Just
the fact that the signal was caught should cause msgrcv to return.
I'm worried about the alarm clobbering msgrcv() and causing it to
drop a message. Does msgrcv guard against this?
Please confirm my fears or set my mind at ease.
--
Mike Maloney "That's like saying 'if we had
Integral Systems, Inc. eggs we could have bacon and eggs
Lanham, Maryland 20706 if we had bacon'" - Sid
(301) 731-4233 ext. 165
More information about the Comp.unix.questions
mailing list