Solved

signal() and sigaction() ?

Posted on 2002-05-26
3
667 Views
Last Modified: 2010-05-18
Hi
Can anyone tell me the difference between signal and sigaction? I am having an alarm which interrupts a blocking recvfrom call every 10 seconds. When I used signal to specify the function to handle SIGALRM signal, the signal was handled but the recvfrom did not return after the alarm was processed.
When I used sigaction, recvfrom call was interrupted and after executing the signal handling function it proceded to the next line in my program. I thought both signal and sigaction could be used interchangably for
specifying the signal handling functions.
Thanks
Sreekumar.
0
Comment
Question by:sreekumarvk
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
ecw earned 100 total points
ID: 7036600
BSD semantics - some sys calls are restartable if a signal is received during the call.  sigaction has a flag to enable this - SA_RESTART.  Set this and both your tests will do the same.  If you're were using SYSV semantics, your recvfrom would return an EINTR if you used signal, and an alarm was received.
0
 

Author Comment

by:sreekumarvk
ID: 7037373
Hi ecw,
Thanks for the help.. Now things are more clear.
Sreekumar
0
 
LVL 5

Expert Comment

by:ecw
ID: 7037871
No worries.  There a good description of signal handling in the comp.unix.programming faq.  It might apply to Linux too, although not everything is the same, the faq is a good place to start, see
  http://www.erlenstar.demon.co.uk/unix/faq_toc.html
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question