Arrange to return a non-zero exit code if the SDR thread unexpectedly halts
This commit is contained in:
parent
47e43778a6
commit
9dfc3e7aa6
21
dump1090.c
21
dump1090.c
|
@ -224,15 +224,12 @@ void *readerThreadEntryPoint(void *arg)
|
||||||
|
|
||||||
// Wake the main thread (if it's still waiting)
|
// Wake the main thread (if it's still waiting)
|
||||||
pthread_mutex_lock(&Modes.data_mutex);
|
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_cond_signal(&Modes.data_cond);
|
||||||
pthread_mutex_unlock(&Modes.data_mutex);
|
pthread_mutex_unlock(&Modes.data_mutex);
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
pthread_exit(NULL);
|
|
||||||
#else
|
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// ============================== Snip mode =================================
|
// ============================== Snip mode =================================
|
||||||
|
@ -760,15 +757,15 @@ int main(int argc, char **argv) {
|
||||||
display_total_stats();
|
display_total_stats();
|
||||||
}
|
}
|
||||||
|
|
||||||
log_with_timestamp("Normal exit.");
|
|
||||||
|
|
||||||
sdrClose();
|
sdrClose();
|
||||||
|
|
||||||
#ifndef _WIN32
|
if (Modes.exit == 1) {
|
||||||
pthread_exit(0);
|
log_with_timestamp("Normal exit.");
|
||||||
#else
|
return 0;
|
||||||
return (0);
|
} else {
|
||||||
#endif
|
log_with_timestamp("Abnormal exit.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
|
@ -304,7 +304,7 @@ struct { // Internal state
|
||||||
double sample_rate; // actual sample rate in use (in hz)
|
double sample_rate; // actual sample rate in use (in hz)
|
||||||
|
|
||||||
uint16_t *log10lut; // Magnitude -> log10 lookup table
|
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
|
// Sample conversion
|
||||||
int dc_filter; // should we apply a DC filter?
|
int dc_filter; // should we apply a DC filter?
|
||||||
|
|
Loading…
Reference in a new issue