Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!dg-rtp!dg!pigpen!lippert From: lippert@pigpen.rtp.dg.com (Mike Lippert) Newsgroups: comp.lang.c Subject: Re: Signal handling on sockets Keywords: Signals , Sockets Message-ID: <709@dg.dg.com> Date: 4 Aug 90 01:25:12 GMT References: <3271@stl.stc.co.uk> Sender: root@dg.dg.com Reply-To: lippert@pigpen.dg.com (Mike Lippert) Distribution: comp.lang.c Organization: Data General Corporation, Westboro, MA Lines: 36 In article <3271@stl.stc.co.uk> "Steve Perryman " writes: > >I have a signal handling problem I am unable to resolve. > >I have set up a signal handler to record whenever a socket receives data >(using the "signal" operation with the SIGIO/SIGPOLL code) ... ... >The problem I have is that my test harness sends n messages to the socket in >succession (the real application could receive any number of data items at any >time) and the signal handler is invoked ONCE ONLY. After putting in a loop >to delay the transmission of each data item, the signal handler was invoked >the correct number of times. This suggests a timing/race problem at the >receiving end. > >What I would like to know is how to set the signal handler so it acknowledges >every signal regardless of the speed and frequency of receipt of data at the >socket (if this is possible). > >Steven Perryman >(skp@stl.stc.co.uk) Not that this will necessarily solve your problem (I'm just starting to play w/ UNIX myself) but as I understand it you should use sigset() instead of signal(). sigset() does not allow the trap routine to be interrupted by another of the same signal. It also (I think) does not require you to reset the signal handler, within the signal handler as signal() does. Also I understand signals in unix, the best you can do is be handling 1 signal and have 1 pended, any more that arrive while 1 is pended will be lost, therefore your signal handler should not expect 1 event per signal, but rather 0+ events, ie you should handle *all* events waiting including *no* events waiting. -- Michael J. Lippert ---- internet --> lippert@pigpen.rtp.dg.com