Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,8 @@ int main(int argc, char *argv[]) {
signal(SIGUSR2, SIG_IGN);
#endif /* _WIN32 */

olsr_shutdown_registered = true;

/* Starting scheduler */
olsr_scheduler();

Expand Down
10 changes: 9 additions & 1 deletion src/olsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ bool changes_neighborhood;
bool changes_hna;
bool changes_force;

bool olsr_shutdown_registered = false;

/*COLLECT startup sleeps caused by warnings*/

#ifdef OLSR_COLLECT_STARTUP_SLEEP
Expand Down Expand Up @@ -576,7 +578,13 @@ olsr_exit(const char *msg, int val)
olsr_cnf->exit_value = val;
}

raise(SIGTERM);
/* Only take the orderly shutdown path once olsr_shutdown() is
* installed. Before that, SIGTERM still has its default disposition
* and raise() would kill us outright, so the exit() below would never
* run and the process would report 143 instead of val. */
if (olsr_shutdown_registered) {
raise(SIGTERM);
}

/* in case the signal handler was not setup yet */
exit(val);
Expand Down
2 changes: 2 additions & 0 deletions src/olsr.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ extern bool changes_neighborhood;
extern bool changes_hna;
extern bool changes_force;

extern bool olsr_shutdown_registered;

extern union olsr_ip_addr all_zero;

void get_argc_argv(int *argc, char **argv[]);
Expand Down
Loading