diff --git a/gtests/net/packetdrill/run.c b/gtests/net/packetdrill/run.c index 705adce056999c0dd55b6ba32c3eab1f5ac5a495..f2f32d6724bf83fe9d8b0d3df690080664c01b97 100644 --- a/gtests/net/packetdrill/run.c +++ b/gtests/net/packetdrill/run.c @@ -8,7 +8,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See thest * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -66,13 +66,6 @@ const int MAX_SPIN_USECS = 20; static struct state *state = NULL; -void interrupt_handler(int signal_number) { - if (state != NULL) - state_free(state); - - die("interrupted"); -} - struct state *state_new(struct config *config, struct script *script, struct netdev *netdev) @@ -502,14 +495,21 @@ static s64 schedule_start_time_usecs(void) #endif } +void signal_handler(int signal_number) { + if (state != NULL) + close_all_sockets(state); + + die("Handled signal %d", signal_number); +} + void run_script(struct config *config, struct script *script) { char *error = NULL; struct netdev *netdev = NULL; struct event *event = NULL; - if (signal(SIGINT, interrupt_handler) == SIG_ERR) { - die("could not set up interrupt handler for SIGINT!"); + if (signal(SIGINT, signal_handler) == SIG_ERR) { + die("could not set up signal handler for SIGINT!"); } DEBUGP("run_script: running script\n");