[v3,1/3] app/dumpcap: handle SIGTERM and SIGHUP
Checks
Commit Message
If the dumpcap is killed it does not cleanup which leaves
the ring buffer and the memory pool behind.
Until resource are exhausted devices will continue to fill the ring.
Fix by having the application handle SIGTERM, SIGHUP, and SIGPIPE.
These are the same signals handled in same way by the wireshark
dumpcap application.
Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/dumpcap/main.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
@@ -936,6 +936,11 @@ int main(int argc, char **argv)
{
struct rte_ring *r;
struct rte_mempool *mp;
+ struct sigaction action = {
+ .sa_flags = SA_RESTART,
+ .sa_handler = signal_handler,
+ };
+ struct sigaction origaction;
dumpcap_out_t out;
char *p;
@@ -961,8 +966,13 @@ int main(int argc, char **argv)
compile_filters();
- signal(SIGINT, signal_handler);
- signal(SIGPIPE, SIG_IGN);
+ sigemptyset(&action.sa_mask);
+ sigaction(SIGTERM, &action, NULL);
+ sigaction(SIGINT, &action, NULL);
+ sigaction(SIGPIPE, &action, NULL);
+ sigaction(SIGHUP, NULL, &origaction);
+ if (origaction.sa_handler == SIG_DFL)
+ sigaction(SIGHUP, &action, NULL);
enable_primary_monitor();