Skip to content

Commit

Permalink
Provide proper exit code for signals
Browse files Browse the repository at this point in the history
Currently ipmid only exits 0, allow it to exit based
on the signal captured.

Tested:

journalctl -u phosphor-pid-control -o json-pretty

{
        "_SYSTEMD_SLICE" : "-.slice",
        "_GID" : "0",
        "_CAP_EFFECTIVE" : "3fffffffff",
        "MESSAGE" : "phosphor-ipmi-host.service: Main process exited, code=killed, status=9/KILL",
        "EXIT_STATUS" : "9",
        "__CURSOR" : "s=cd10fcb9010e4cfdbcdad08709c2265d;i=399;b=2efcc2f735f74bc99588861556589a72;m=7c0ed53;t=592853b62b677;x=1ae3833ab435621e",
        "__MONOTONIC_TIMESTAMP" : "130084179",
        "MESSAGE_ID" : "98e322203f7a4ed290d09fe03c09fe15",
        "_EXE" : "/lib/systemd/systemd",
        "CODE_LINE" : "5797",
        "UNIT" : "phosphor-ipmi-host.service",
        "_SYSTEMD_CGROUP" : "/init.scope",
        "_SYSTEMD_UNIT" : "init.scope",
        "SYSLOG_IDENTIFIER" : "systemd",
        "_COMM" : "systemd",
        "_UID" : "0",
        "PRIORITY" : "4",
        "_HOSTNAME" : "intel-obmc",
        "SYSLOG_FACILITY" : "3",
        "CODE_FILE" : "src/core/unit.c",
        "CODE_FUNC" : "unit_log_process_exit",
        "_CMDLINE" : "/lib/systemd/systemd",
        "__REALTIME_TIMESTAMP" : "1568475808183927",
        "_SOURCE_REALTIME_TIMESTAMP" : "1568475808183827",
        "COMMAND" : "ExecStart",
        "INVOCATION_ID" : "67ff87a3ad4b4a4da3fe7e0ff083e2b8",
        "_TRANSPORT" : "journal",
        "_MACHINE_ID" : "f7182be05e2147feba2eaceaea0aded3",
        "_BOOT_ID" : "2efcc2f735f74bc99588861556589a72",
        "EXIT_CODE" : "killed",
        "_PID" : "1"
}

Change-Id: I9f3233546b43a331076d21b73beabbf2aaca9d8b
Signed-off-by: James Feist <james.feist@linux.intel.com>
  • Loading branch information
feistjj authored and tomjoseph83 committed Nov 27, 2019
1 parent 76ce9c7 commit b0094a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ipmid-new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,12 +861,14 @@ int main(int argc, char* argv[])
ipmi::nameChangeHandler);
ipmi::doListNames(*io, *sdbusp);

int exitCode = 0;
// set up boost::asio signal handling
std::function<SignalResponse(int)> stopAsioRunLoop =
[&io](int signalNumber) {
[&io, &exitCode](int signalNumber) {
log<level::INFO>("Received signal; quitting",
entry("SIGNAL=%d", signalNumber));
io->stop();
exitCode = signalNumber;
return SignalResponse::breakExecution;
};
registerSignalHandler(ipmi::prioOpenBmcBase, SIGINT, stopAsioRunLoop);
Expand All @@ -882,5 +884,5 @@ int main(int argc, char* argv[])
// unload the provider libraries
providers.clear();

return 0;
std::exit(exitCode);
}

0 comments on commit b0094a7

Please sign in to comment.