On Sun, 6 Nov 2022 13:50:36 +0300 Andrew Rybchenko <andrew.rybche...@oktetlabs.ru> wrote:
> On 10/14/22 20:23, Stephen Hemminger wrote: > > The original behavior of testpmd was to kill itself when > > it received a SIGINT or SIGTERM. This makes it hard to use > > testpmd in test automation where forwarding loop is started > > and then stopped via SIGTERM. > > Can automatic stop it using SIGINT? Doesn't matter the testpmd code has same bug in SIGINT and SIGTERM. The fundamental problem is that regular signals in Unix model are delivered to the process and any thread may receive them. In the case of testpmd, the signal may arrive inside some driver which is doing some operations with hardware and even holding a lock. Then signal_handler() is called. This code does operations that may interact with driver and other parts of the system. It is a broken way to handle this. There are two ways to handle this problem. One way would be to block the signals and use signalfd() and epoll() to handle them. This would be more difficult and invasive in the testpmd logic. The simpler way is to just set a flag and do the cleanup in the main loop when the flag is detected.