[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Signal doesn't interrupt read() and wait() - help!
Konrad Kokoszkiewicz <draco@mi.com.pl> writes:
|>> I think this short program might help to explain the problem. Try it out
|>> and see that when the alarm signal arrives, the read() call does not
|>> return like it seems it should.
|>>
|>> This just shows the problem in read(), it also happens in wait() and
|>> perhaps others.
|>>
|>> So now that you can see the problem happening in front of you, perhaps
|>> someone has some other ideas about why this is.
|> I compiled it on our server here (RedHat Linux, kernel 2.0.31). It behaves
|> exactly the same - i.e. the read() call waits until you press Enter and
|> doesn't return automatically after 5 seconds. The signal however is
|> delivered (the appropriate variable changes).
You should be using sigaction to make syscalls interruptable. If you use
plain signal the default action will depend on the system (and even on
libc version in Linux), but with sigaction you have the complete control,
depending on whether you use SA_RESTART (except under MiNT, where syscalls
are *never* interruptable :-( ).
Andreas.
--
Andreas Schwab "And now for something
schwab@issan.informatik.uni-dortmund.de completely different"
schwab@gnu.org