Details
-
Bug
-
Resolution: Done
-
P4: Low
-
5.14.2
-
None
-
1
-
7cbe7f97ad7585c72b18f786b83122840f7159cc (qt/qtdoc/5.15.0)
-
Da Vinci sprint 7
Description
In the documentation at address https://doc.qt.io/qt-5/unix-signals.html in the sample for the
setup_unix_signal_handlers() function there is a bug:
static int setup_unix_signal_handlers() { struct sigaction hup, term; hup.sa_handler = MyDaemon::hupSignalHandler; sigemptyset(&hup.sa_mask); hup.sa_flags = 0; hup.sa_flags |= SA_RESTART; if (sigaction(SIGHUP, &hup, 0)) return 1; term.sa_handler = MyDaemon::termSignalHandler; sigemptyset(&term.sa_mask); term.sa_flags |= SA_RESTART; if (sigaction(SIGTERM, &term, 0)) return 2; return 0; }
The field sa_flags of the structure term is not initialized to zero, so SA_RESTART is in OR with whatever value was in the memory. It should be set to zero as already done for the structure hup:
static int setup_unix_signal_handlers() { struct sigaction hup, term; hup.sa_handler = MyDaemon::hupSignalHandler; sigemptyset(&hup.sa_mask); hup.sa_flags = 0; hup.sa_flags |= SA_RESTART; if (sigaction(SIGHUP, &hup, 0)) return 1; term.sa_handler = MyDaemon::termSignalHandler; sigemptyset(&term.sa_mask); term.sa_flags = 0; term.sa_flags |= SA_RESTART; if (sigaction(SIGTERM, &term, 0)) return 2; return 0; }
Attachments
For Gerrit Dashboard: QTBUG-83686 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
297793,3 | Doc: Fix snippet | 5.15.0 | qt/qtdoc | Status: MERGED | +2 | 0 |