From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd Date: Thu, 24 Dec 2015 09:51:34 -0800 Message-ID: <20151224095134.6eea3d4b@xeon-e3> References: <1450900995-84185-1-git-send-email-zhihong.wang@intel.com> <1450900995-84185-4-git-send-email-zhihong.wang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Zhihong Wang Return-path: Received: from mail-ig0-f172.google.com (mail-ig0-f172.google.com [209.85.213.172]) by dpdk.org (Postfix) with ESMTP id 86F608DED for ; Thu, 24 Dec 2015 18:51:26 +0100 (CET) Received: by mail-ig0-f172.google.com with SMTP id to18so99123185igc.0 for ; Thu, 24 Dec 2015 09:51:26 -0800 (PST) In-Reply-To: <1450900995-84185-4-git-send-email-zhihong.wang@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, 23 Dec 2015 15:03:15 -0500 Zhihong Wang wrote: > +/* When we receive a INT signal, close all ports */ > +static void > +sigint_handler(__rte_unused int signum) > +{ > + unsigned portid, nb_ports; > + > + printf("Preparing to exit...\n"); > + nb_ports = rte_eth_dev_count(); > + for (portid = 0; portid < nb_ports; portid++) { > + if ((enabled_port_mask & (1 << portid)) == 0) { > + continue; > + } > + printf("Stopping port %d...", portid); > + rte_eth_dev_stop(portid); > + rte_eth_dev_close(portid); > + printf(" Done\n"); > + } > + printf("Bye...\n"); > + exit(0); > +} Signal handlers should only set a flag, which is then checked by thread loops. Calling functions in DPDK from signal handlers is not safe.