[PATCH v4] testpmd: cleanup cleanly from signal

Mattias Rönnblom hofors at lysator.liu.se
Thu Nov 10 23:06:55 CET 2022


On 2022-11-10 17:14, Stephen Hemminger wrote:
> 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.

I had no doubts about that, but I misunderstood the code and thought 
that was the required behavior.


More information about the dev mailing list