#include <ctype.h>
#include <errno.h>
#include <getopt.h>
+#include <signal.h>
#include <rte_common.h>
#include <rte_log.h>
/* Keepalive structure */
struct rte_keepalive *rte_global_keepalive_info;
+/* Termination signalling */
+static int terminate_signal_received;
+
+/* Termination signal handler */
+static void handle_sigterm(__rte_unused int value)
+{
+ terminate_signal_received = 1;
+}
+
/* Print out statistics on packets dropped */
static void
print_stats(__attribute__((unused)) struct rte_timer *ptr_timer,
uint64_t tsc_initial = rte_rdtsc();
uint64_t tsc_lifetime = (rand()&0x07) * rte_get_tsc_hz();
- while (1) {
+ while (!terminate_signal_received) {
/* Keepalive heartbeat */
rte_keepalive_mark_alive(rte_global_keepalive_info);
static void
dead_core(__rte_unused void *ptr_data, const int id_core)
{
+ if (terminate_signal_received)
+ return;
printf("Dead core %i - restarting..\n", id_core);
if (rte_eal_get_lcore_state(id_core) == FINISHED) {
rte_eal_wait_lcore(id_core);
uint8_t portid, last_port;
unsigned lcore_id, rx_lcore_id;
unsigned nb_ports_in_mask = 0;
+ struct sigaction signal_handler;
+
+ memset(&signal_handler, 0, sizeof(signal_handler));
+ terminate_signal_received = 0;
+ signal_handler.sa_handler = &handle_sigterm;
+ if (sigaction(SIGINT, &signal_handler, NULL) == -1 ||
+ sigaction(SIGTERM, &signal_handler, NULL) == -1)
+ rte_exit(EXIT_FAILURE, "SIGNAL\n");
+
/* init EAL */
ret = rte_eal_init(argc, argv);
lcore_id);
}
}
- for (;;) {
+ while (!terminate_signal_received) {
rte_timer_manage();
rte_delay_ms(5);
}