/*
- * Copyright (c) 2014 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 - 2021 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <signal.h>
#include <errno.h>
#include <cassert>
+#include <cstring>
#include <systemd/sd-daemon.h>
{
LogDebug("Get signal information");
- if (sizeof(struct signalfd_siginfo) != event.rawBuffer.size()) {
+ signalfd_siginfo siginfo;
+ if (sizeof(siginfo) != event.rawBuffer.size()) {
LogError("Wrong size of signalfd_siginfo struct. Expected: "
- << sizeof(signalfd_siginfo) << " Get: "
+ << sizeof(siginfo) << " Get: "
<< event.rawBuffer.size());
return;
}
- auto siginfo = reinterpret_cast<const signalfd_siginfo *>
- (event.rawBuffer.data());
+ memcpy(&siginfo, event.rawBuffer.data(), sizeof(siginfo));
- if (siginfo->ssi_signo == SIGTERM) {
+ if (siginfo.ssi_signo == SIGTERM) {
LogInfo("Got signal: SIGTERM");
m_serviceManager->MainLoopStop();
return;
}
- LogInfo("This should not happend. Got signal: " << siginfo->ssi_signo);
+ LogInfo("This should not happen. Got unexpected signal: " << siginfo.ssi_signo);
}
};