Arrange to return a non-zero exit code if the SDR thread unexpectedly halts

This commit is contained in:
Oliver Jowett 2019-03-07 18:35:47 +00:00
parent 47e43778a6
commit 9dfc3e7aa6
2 changed files with 10 additions and 13 deletions

View file

@ -224,15 +224,12 @@ void *readerThreadEntryPoint(void *arg)
// Wake the main thread (if it's still waiting)
pthread_mutex_lock(&Modes.data_mutex);
Modes.exit = 1; // just in case
if (!Modes.exit)
Modes.exit = 2; // unexpected exit
pthread_cond_signal(&Modes.data_cond);
pthread_mutex_unlock(&Modes.data_mutex);
#ifndef _WIN32
pthread_exit(NULL);
#else
return NULL;
#endif
}
//
// ============================== Snip mode =================================
@ -760,15 +757,15 @@ int main(int argc, char **argv) {
display_total_stats();
}
log_with_timestamp("Normal exit.");
sdrClose();
#ifndef _WIN32
pthread_exit(0);
#else
return (0);
#endif
if (Modes.exit == 1) {
log_with_timestamp("Normal exit.");
return 0;
} else {
log_with_timestamp("Abnormal exit.");
return 1;
}
}
//
//=========================================================================

View file

@ -304,7 +304,7 @@ struct { // Internal state
double sample_rate; // actual sample rate in use (in hz)
uint16_t *log10lut; // Magnitude -> log10 lookup table
int exit; // Exit from the main loop when true
int exit; // Exit from the main loop when true (2 = unclean exit)
// Sample conversion
int dc_filter; // should we apply a DC filter?