work-around for EINTR error



Hi,

We're porting a multithreaded application to Linux using the NPTL
pthreads library, and using gdb/eclipse for debugging. When gdb wants
to stop the application (breakpoints and single stepping), it sends a
SIGSTOP to all threads within the process.

Reading the manpages, I found that a lot of system + std libary calls
may be interrupted by this (and other) signals and return with EINTR.
Apparently it's up to the user to explicitly "restart" such calls,
taking into account extra difficulties for some:
- sleeps must be restarted with remaining time
- writes must be restarted with the remaining number of bytes
- (f)printf can be interrupted in the midst of printing output
- (f)scanf can be interrupted while reading input

I find it at least cumbersome to implement such behaviour at
application level (is there any reason why one would not want to
restart the call ?). And it's also a risk, because there are really a
lot of calls which may be interrupted and it's easy to overlook one,
possibly yielding sporadic erroneous behavior.

Now I wonder whether there is a standard work-around for this problem,
like:
- some setting or hack to avoid call interruption
- a glibc version/patch that automatically restart calls
- a reference "wrapper" doing the restart
- any other...


Thanks,
Pieter

.



Relevant Pages

  • Re: work-around for EINTR error
    ... may be interrupted by this signals and return with EINTR. ... Apparently it's up to the user to explicitly "restart" such calls, ... possibly yielding sporadic erroneous behavior. ... some setting or hack to avoid call interruption ...
    (comp.os.linux.development.apps)
  • Re: RiffTrax: How close do you try to get your sync?
    ... I come back to a movie after an interruption, ... you want to restart, un-pause them in the same order that you paused ...
    (rec.arts.tv.mst3k.misc)
  • What services can be safely restarted during day?
    ... I was just curious which services are safe to restart during the ... business day. ... I don't want to cause any interruption to what my users ... long as my users don't see any problems in their Outlook ...
    (microsoft.public.exchange.admin)