Restartable system call behaviour

Yar Tikhiy yar at comp.chem.msu.su
Wed Feb 1 14:07:34 PST 2006


On Wed, Feb 01, 2006 at 08:48:30PM +0000, Pete French wrote:
> > >>I have a piece of coode which does some networking, in which I see read
> > >>and write calls failing with 'Interrupted system call' from time to time.
> > > 
> > > You will get EINTR if the interrupt occurs before any data is read
> > > or written.
> >
> > Will it also happen with recv() with MSG_WAITALL flag set?
> 
> Actually I have narrowed this down now, and I wwas wrong in the original
> posting - I was getting the EINTR returned by connect. Now I am not
> sure if this is correct behaviour or not - if a signal has SA_RESTART set
> then it should restart, but connect returns EINTR and then continues
> to connect in the background.
> 
> I had alwways belived that if system calls are restrtable then you will never
> see EINTR at all. Now I dont know if this is a problem with my understanding
> of how the system works, or an actual bug. have filed a pr anyway, just in
> case it *is* a bug.

To the best of my knowledge, connect() being always interruptable
is correct and well-known.  And my 4.11-STABLE system will interrupt
connect() on a signal with SA_RESTART set, which disagrees with your
observations yet agrees with the standard.  Perhaps some logic in
your software has changed since 4.11 times.

Your software can poll, select, or just loop over connect() until
errno != EALREADY if connect() returned EINTR.

-- 
Yar


More information about the freebsd-stable mailing list