What is meant by (a signal is caught and returns)

What is meant by (a signal is caught and returns)

Post by Scott Watso » Thu, 02 Nov 2000 23:31:55



In Richard Stevens book, under the section for Message queues I found the
statement that msgrcv will unblock when either

a) there is data
b) the queue has been removed from the system and an error EIDRM is returned
c) a signal is caught and returns in which case the error is set to EINTR.

Could someone please clarify what that (c) means.  Are there any signals
that "return" by default?

Thanks,
scott.

 
 
 

What is meant by (a signal is caught and returns)

Post by John Simpso » Fri, 03 Nov 2000 01:41:52


 >
 > In Richard Stevens book, under the section for Message queues I found
the
 > statement that msgrcv will unblock when either
 >
 > a) there is data
 > b) the queue has been removed from the system and an error EIDRM is
returned
 > c) a signal is caught and returns in which case the error is set to
EINTR.
 >
 > Could someone please clarify what that (c) means.  Are there any
signals
 > that "return" by default?
 >
 > Thanks,
 > scott.

Look at your man pages for sigaction().  Basically, if you set up a
procedure to handle a signal delivered to your process, when the signal
is recieved, that procedure is invoked.  In general, when the procedure
completes, control is passed to the statement following the point at
which the signal was received.  In your case, suppose you received a
SIGCLD from an exiting child process while you were in the process of
doing the msgrcv().  Your SIGCLD handler would do it's thing and then
return control to the statement following the msgrcv().  The return from
msgrcv() will be -1 and errno will be set to EINTR, indicating that the
msgrcv() call was interrupted.  In general, it is good practice to put
the msgrcv() in a while loop that tests for a -1 return and errno ==
EINTR so that you go back to the msgrcv() if you are interrupted.  

hth

--
John H. Simpson Phone: 503-450-2667  FAX: 503-450-3629
CNF AdTech Center. (CNF, Inc.)
1717 NW 21st St.
Portland, OR 97209 USA

 
 
 

What is meant by (a signal is caught and returns)

Post by Bryan Polya » Fri, 03 Nov 2000 01:49:29


Scott,

Basically, c) is saying that if the application receives any unblocked signal,
and the signal handler returns (rather exiting the app), then msgrcv will also
return with the error set to EINTR.

Signals themselves don't return.  They are sent by some process, and received
(or caught) by another (perhaps the same process).  If you use default signal
handling (meaning you haven't installed your own handler), then some signals do
cause the handler to return.  Look at Chapter 10 of Stevens' book for more about
signals.

Hope this helps,
Bryan


> In Richard Stevens book, under the section for Message queues I found the
> statement that msgrcv will unblock when either

> a) there is data
> b) the queue has been removed from the system and an error EIDRM is returned
> c) a signal is caught and returns in which case the error is set to EINTR.

> Could someone please clarify what that (c) means.  Are there any signals
> that "return" by default?

> Thanks,
> scott.

 
 
 

1. This clone thing...am I stupid, or am I right?


says...

I admire your passion, Chris..

The only issues which have kept myself from looking seriously at Linux
would be:

* It's Unix and the learning curve to start getting productive strikes me
as probably very steep

* It doesn't support plug-and-play.  If your hardware doesn't have Linux
drivers, it don't play..

* Not nearly the amount of developers out there doing stuff for Linux as
there are for Wintel.  Can I get MS Office for Linux?  Can I get
Photoshop for Linux?  Can I get QuarkXpress for Linux? etc.. a big turn
off for me.

--
Reuben King
Email: "reuben at texas dot net" (in plain english to foil spam-bots.
grrr!)

2. multiboot NT/Linux +bootpart

3. Status on GCC 2.8.1

4. I am with the following error, when i am running lilo...

5. asd

6. Am I touchy? Or am I right?

7. Printing to Apple LaserWriter 8500 remote

8. Am I seeing IPv5, or am I hallucinating?

9. I am buying an Ultra 5 but am lost in part numbers ....

10. I am in text mode, what browser am I running....

11. I am si**y am I?

12. G++ 2.8.1 on FreeBSD: Exceptions are not caught, what am I doing wrong?