Add a configure option to exit on poll errors

If an error is returned from qt_safe_poll inside the event dispatcher
the error is currently printed and ignored.

For most cases this behavior seems to be fine, but when used in critical
systems e.g. automotive or medical, a error might indicate a more severe
problem and the application should be stopped instead.
The system can then decide itself what to do e.g. restarting the
application using a watchdog.

Change-Id: Iaf5abb20bb3941eaeff19d14e41c395c88fa088d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Dominik Holland 2022-09-27 09:51:24 +02:00
parent 35ff456407
commit 0e1ce757d5
2 changed files with 12 additions and 0 deletions

View File

@ -961,6 +961,13 @@ qt_feature("cborstreamwriter" PUBLIC
LABEL "CBOR stream writing" LABEL "CBOR stream writing"
PURPOSE "Provides support for writing the CBOR binary format." PURPOSE "Provides support for writing the CBOR binary format."
) )
qt_feature("poll-exit-on-error" PUBLIC
LABEL "Poll exit on error"
AUTODETECT OFF
CONDITION UNIX
PURPOSE "Exit on error instead of just printing the error code and continue."
)
qt_feature_definition("poll-exit-on-error" "QT_POLL_EXIT_ON_ERROR")
qt_configure_add_summary_section(NAME "Qt Core") qt_configure_add_summary_section(NAME "Qt Core")
qt_configure_add_summary_entry(ARGS "backtrace") qt_configure_add_summary_entry(ARGS "backtrace")
qt_configure_add_summary_entry(ARGS "doubleconversion") qt_configure_add_summary_entry(ARGS "doubleconversion")
@ -970,6 +977,7 @@ qt_configure_add_summary_entry(ARGS "icu")
qt_configure_add_summary_entry(ARGS "system-libb2") qt_configure_add_summary_entry(ARGS "system-libb2")
qt_configure_add_summary_entry(ARGS "mimetype-database") qt_configure_add_summary_entry(ARGS "mimetype-database")
qt_configure_add_summary_entry(ARGS "cpp-winrt") qt_configure_add_summary_entry(ARGS "cpp-winrt")
qt_configure_add_summary_entry(ARGS "poll-exit-on-error")
qt_configure_add_summary_entry( qt_configure_add_summary_entry(
TYPE "firstAvailableFeature" TYPE "firstAvailableFeature"
ARGS "etw lttng" ARGS "etw lttng"

View File

@ -466,7 +466,11 @@ bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags)
switch (qt_safe_poll(d->pollfds.data(), d->pollfds.size(), tm)) { switch (qt_safe_poll(d->pollfds.data(), d->pollfds.size(), tm)) {
case -1: case -1:
#ifdef QT_POLL_EXIT_ON_ERROR
qFatal("qt_safe_poll errno: %i error: %ls", errno, qUtf16Printable(qt_error_string()));
#else
perror("qt_safe_poll"); perror("qt_safe_poll");
#endif
break; break;
case 0: case 0:
break; break;