RDKEMW-12824: Propagate signal from DobbyInit to DobbyDaemon #434
RDKEMW-12824: Propagate signal from DobbyInit to DobbyDaemon #434
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to correctly propagate “signal-killed” container termination causes from DobbyInit (PID 1 in the container PID namespace) up to DobbyDaemon, by encoding the terminating signal as an exit code (128 + signum) and reconstructing a WIFSIGNALED-style wait status in the daemon.
Changes:
DobbyInit: record a received/observed terminating signal and_exit(128 + sig)after reaping children.DobbyManager: detectWEXITSTATUSin the128+sigrange and synthesize aWIFSIGNALED-compatible wait status (optionally settingWCOREDUMP).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
daemon/lib/source/DobbyManager.cpp |
Decodes 128+sig exits into synthesized WIFSIGNALED statuses (plus optional WCOREDUMP). |
daemon/init/source/InitMain.cpp |
Tracks signal receipt/child signal death and exits via the 128+sig convention. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (WIFEXITED(status)) | ||
| { | ||
| int exitCode = WEXITSTATUS(status); | ||
| if (exitCode > 128 && exitCode <= 128 + 64) | ||
| { | ||
| int sig = exitCode - 128; | ||
| AI_LOG_INFO("container '%s' exited with code %d, " | ||
| "interpreting as killed by signal %d (%s) " | ||
| "(PID 1 namespace init convention)", | ||
| id.c_str(), exitCode, sig, strsignal(sig)); | ||
|
|
There was a problem hiding this comment.
There are L1 tests for DobbyManager, but this new “exit code 128+signal => synthesized WIFSIGNALED” behavior appears untested. Adding a focused unit/integration test that exercises onChildExit handling for (a) a signaled container and (b) a normal exit code in the 129–192 range would help prevent regressions and validate the chosen encoding/decoding scheme.
Description
When a container is killed by a signal, DobbyDaemon expects to see a WIFSIGNALED wait status from the container's runc process. However, DobbyInit is PID 1 of the container's PID namespace and the kernel protects it from signals with default disposition - even raise() is silently dropped, making the conventional "reset to SIG_DFL + raise()" approach impossible.
As a result, DobbyInit was exiting with code 0 regardless of the signal received, causing DobbyDaemon to incorrectly treat signal-killed containers as clean exits (WIFEXITED, status 0x0000).
Adopt the POSIX shell convention: record the signal number in a volatile sig_atomic_t from the signal handler, and after all children have been reaped call _exit(128 + signum). On the DobbyDaemon side, detect exit codes in the range 129-192 and synthesise the equivalent WIFSIGNALED wait status.
Test Procedure
Sending a SIGABRT or SIGSEGV or any other fatal message to DobbyInit or another process within the running container results in the app crashing as expected.
Expected:
Type of Change
Requires Bitbake Recipe changes?
meta-rdk-ext/recipes-containers/dobby/dobby.bb) must be modified to support the changes in this PR (beyond updatingSRC_REV)