Skip to navigation

holoscan::ManagedShutdownSignals

Beta
View as Markdown

Own one early process domain for managed SIGINT and SIGTERM acceptance.

On Linux, create this object on the initial application thread before other participant threads are started. Threads created afterward inherit its managed-signal mask. The object is creator-thread-affine, supports one managed run binding, and must outlive that binding and every participant thread. On unsupported platforms, create() reports kNotSupported.

The type is move-constructible on its creator thread but is neither copyable nor move-assignable. A moved-from or successfully closed object has no domain. Public operations on one domain are not thread-safe and must be serialized on the creator thread. Establishment may allocate, create descriptors, and start one ordinary broker thread. The domain installs no signal handler and does not change the application’s SIGINT or SIGTERM dispositions.

A domain that successfully reserves a managed run binding is spent after that attempt; create a new domain for another managed run. HSDK use of an inherited domain after fork(), and host mutation of the managed masks or dispositions, are currently unsupported. Domain descriptors are close-on-exec, but the blocked signal mask is inherited by a child and survives exec(). Before executing another program, reset the child mask with sigprocmask() or use POSIX_SPAWN_SETSIGMASK with an application-chosen mask. HSDK does not intercept exec(); detectable post-fork API use reports kNotSupported.

#include <holoscan/managed_shutdown_signals.hpp>

Constructors

ManagedShutdownSignals

Transfer the domain owner without changing creator-thread affinity.

Move only on the creator thread; moving does not transfer thread affinity or permit concurrent access.

Destructor

~ManagedShutdownSignals

Attempt best-effort containment for a domain not explicitly closed.

Prefer close() so failures remain observable. On the creator thread, destruction may request cooperative stop for an active binding and wait without a whole-run bound before closing. Destruction on another thread or irreparable cleanup poisons later managed admission; it never throws.


Assignment operators

operator=

The following overloads are deleted to prevent misuse:


Methods

close

expected<void, Error> holoscan::ManagedShutdownSignals::close() noexcept

Close this domain and restore the creator thread’s exact prior signal mask.

Call this on the creator thread after the bound session and every participant thread have retired. An active binding reports kNotReady without consuming the domain and may be retried after RunSession::wait(). A successful close consumes the handle; a repeated close or close on a moved-from object reports kClosed. Wrong-thread use reports kInvalidArgument, post-fork use reports kNotSupported, disposition drift reports kIncompatible, and cleanup failures report kFailure and may poison later managed admission. The call synchronizes with and joins the broker and therefore is not a real-time or bounded-latency operation. After the broker retires, cleanup attempts continue after a primary join, descriptor, disposition, or mask error, including a best-effort exact creator-mask restoration. An error that prevents safe broker retirement instead retains a poisoned domain rather than racing its live state.

Returns: Success, or a bounded wrong-thread, active-binding, or restoration error.


Static methods

create

Establish the sole process managed-shutdown-signal domain.

On Linux, call this before starting any other participant thread. The call snapshots and blocks SIGINT and SIGTERM on the caller, verifies the controlled thread boundary, allocates fixed domain state and descriptors, and starts one broker thread. A competing domain reports kResourceExhausted; an unprepared multithreaded process reports kInvalidArgument; setup failures report kFailure or kResourceExhausted. Non-Linux platforms report kNotSupported. No session is created on failure. Setup is transactional: every safely acquired resource is retired and the exact creator mask and unchanged dispositions are preserved on failure. A rollback failure poisons the process domain so later managed admission fails instead of assuming clean ownership.

Returns: A creator-thread-affine domain, or a bounded setup, ownership, or platform error.


Member variables

NameTypeDescription
impl_std::unique_ptr< Impl >