Skip to content

Robustify dls2 shutdown procedure - #339

Open
mich-pest wants to merge 12 commits into
mainfrom
shutdown_fix
Open

Robustify dls2 shutdown procedure#339
mich-pest wants to merge 12 commits into
mainfrom
shutdown_fix

Conversation

@mich-pest

Copy link
Copy Markdown
Contributor

Making dls2 more robust given the several failure that are occasionally faced by users (e.g. dls_framework not properly killed on shutdown requests). A couple of classes have been added to make the behavior match the expectations after Ctrl+C is pressed.

OwnedProcess class

It belongs to the framework supervision level rather than inside individual layers.
It separates two concerns: layer lifecycle (components handle graceful, semantic shutdown and OS process lifecycle (RunDLS2 owns process groups and ensures all descendants are terminated and reaped).

Detailed procedure:

  • RunDLS2 sends SIGINT to each layer’s process group.
  • Layers perform their normal cleanup.
  • The framework waits for the entire group, including plugins and subprocesses.
  • Stuck processes receive SIGTERM, then SIGKILL as a final fallback.
  • This protects against crashes, orphaned plugins, unavailable DDS communication, ignored signals, and partially initialized components. It complements the existing hierarchy rather than replacing it.

ShutdownSignal class

It converts SIGINT and SIGTERM into safe, application-level shutdown requests, robustifying shutdown behavior for both the framework and individual components.

Detailed procedure:

  • Signal handlers only write to a nonblocking pipe.
  • A worker thread monitors the pipe and invokes the shutdown callback outside signal-handler context.
  • Signals received before initialization are queued and processed later.
  • Repeated signals are coalesced into a single shutdown request.
  • The callback can return false while the component is not ready, allowing the request to be retried.
  • Destruction stops the worker, restores the previous signal handlers, and closes the pipe.

@mich-pest
mich-pest requested a review from MMarcus95 as a code owner September 8, 2026 11:52
@mich-pest mich-pest self-assigned this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant