Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

SIGALRM doesn't interrupt gets()?

I supposed that system calls such gets(), getc() should be interrupted by SIGALRM. And it seems to be true under Unixware 2.01, but it doesn't work under Linux. Why? What should I use to implement timed read?
0
boa
Asked:
boa
1 Solution
 
jos010697Commented:
You're halfway there; the default behavior of 'read' is to
restart after it has been interrupted by a signal _and_ if
nothing has been read just before the signal was raised.
BTW, gets() or getc() aren't system calls; it's the 'read'
call underneath that does all the work.

Check out the sigaction() call; it tells the signal handlers
_not_ to restart certain interrupted system calls ('read' is
one of them), by resetting the SA_RESTART bit ...

kind regards,

Jos aka jos@and.nl
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now