[PATCH v4] testpmd: cleanup cleanly from signal

Stephen Hemminger stephen at networkplumber.org
Thu Nov 10 17:14:12 CET 2022


On Thu, 10 Nov 2022 08:50:40 +0100
Mattias Rönnblom <hofors at lysator.liu.se> wrote:

> >>
> >> Why is select() needed? Wouldn't a blocking read suffice? Or getchar().  
> > 
> > On Linux, signal set SA_RESTART so a simple read is not interrupted.
> > One option was to use sigaction() which allows controlling flags, but that
> > won't work on Windows.  Using select() works on both.
> >   
> 
> OK, so select() is used because a signal might interrupt read() on Windows?
> 
> while (read(0, &c, 1) == -1 && errno == EINTR)
>          ;
> 
> Would that work?

Try it. On Linux the read never gets interrupted.


More information about the dev mailing list