Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amdcad!sun!pitstop!sundc!seismo!uunet!pyrdc!ISIDAPS5!mike From: mike@ISIDAPS5.UUCP (Mike Maloney) Newsgroups: comp.unix.questions Subject: signals interrupting IPC functions Keywords: ...worried about data loss... Message-ID: <216@ISIDAPS5.UUCP> Date: 22 Sep 88 20:44:26 GMT Lines: 32 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