mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(platform): use result to remove -Wunused-result warning
Check for write() and read() results and abort in case of unexpected failure.
This commit is contained in:
parent
6e0bdf2cd2
commit
729dc7740b
|
@ -53,7 +53,12 @@ static void signalHandler(int signum)
|
||||||
if (g_signalSocketUsageFlag.test_and_set())
|
if (g_signalSocketUsageFlag.test_and_set())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
::write(g_signalSocketPair[0], &signum, sizeof(signum));
|
if(::write(g_signalSocketPair[0], &signum, sizeof(signum)) == -1) {
|
||||||
|
// We hardly can do anything more usefull in signal handler, and
|
||||||
|
// any ways it's probably very unexpected error (out of memory?),
|
||||||
|
// since we check socket existance with a flag beforehand.
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
g_signalSocketUsageFlag.clear();
|
g_signalSocketUsageFlag.clear();
|
||||||
}
|
}
|
||||||
|
@ -109,7 +114,9 @@ PosixSignalNotifier& PosixSignalNotifier::globalInstance()
|
||||||
void PosixSignalNotifier::onSignalReceived()
|
void PosixSignalNotifier::onSignalReceived()
|
||||||
{
|
{
|
||||||
int signum{0};
|
int signum{0};
|
||||||
::read(detail::g_signalSocketPair[1], &signum, sizeof(signum));
|
if (::read(detail::g_signalSocketPair[1], &signum, sizeof(signum)) == -1) {
|
||||||
|
qFatal("Failed to read from signal socket, error = %d", errno);
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "Signal" << signum << "received";
|
qDebug() << "Signal" << signum << "received";
|
||||||
emit activated(signum);
|
emit activated(signum);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user