Skip to content
Snippets Groups Projects
Commit afd4a564 authored by Michael Tüxen's avatar Michael Tüxen
Browse files

Improve signal handler.

parent 2e1e2d91
No related branches found
No related tags found
No related merge requests found
......@@ -66,13 +66,6 @@ const int MAX_SPIN_USECS = 20;
static struct state *state = NULL;
void interrupt_handler(int signal_number) {
if (state != NULL)
close_all_sockets(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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment