Skip to content

component: Add CatchSignals option to App#1276

Open
kghost wants to merge 1 commit into
ArthurSonzogni:mainfrom
kghost:skip-signal-handle
Open

component: Add CatchSignals option to App#1276
kghost wants to merge 1 commit into
ArthurSonzogni:mainfrom
kghost:skip-signal-handle

Conversation

@kghost
Copy link
Copy Markdown
Contributor

@kghost kghost commented May 22, 2026

Description

This pull request introduces the CatchSignals option to the App class.

By default, FTXUI installs signal handlers for standard terminate and crash signals (SIGTERM, SIGSEGV, SIGINT, SIGILL, SIGABRT, and SIGFPE) to safely clean up and restore the terminal state before exit.

However, in many host applications (such as those with dedicated crash-reporting, stack-tracing, or customized signal handling), having FTXUI intercept these signals can conflict with standard error handling.

With this change, users can call app.CatchSignals(false); before the main loop to completely skip the installation of these standard signals, leaving them to be handled by the parent process.

Changes Included

  • include/ftxui/component/app.hpp: Added void CatchSignals(bool enable = true); option setter to the App interface.
  • src/ftxui/component/app.cpp: Added bool catch_signals_ = true; flag to App::Internal and conditionalized standard signal installation.
  • src/ftxui/component/app_test.cpp: Added App.CatchSignals_False unit test verifying custom signal handlers are preserved and invoked when CatchSignals(false) is set.

Verification Results

  • All unit tests compiled and executed successfully.
  • Ran ./build/ftxui-tests --gtest_filter="App.*" (all 15 App-related tests passed).
  • Executed the full test suite via ctest with a 100% pass rate (331/331 tests passed).

@ArthurSonzogni
Copy link
Copy Markdown
Owner

Thanks!

I understand the problem you are trying to solve, but I'm not sure about the proposed solution.

If we add an option to stop catching standard signals entirely (like SIGINT or SIGSEGV), any of these signals will cause the application to terminate immediately without cleaning up the terminal state.
This leaves the terminal in a broken state (raw mode active, cursor hidden, etc.).

We need a way to restore the terminal before propagating or letting the process handle the signal.

Please let me 5 days to resolve this properly. I will request a code review from you.

@ArthurSonzogni
Copy link
Copy Markdown
Owner

Hello @kghost,

Does this PR fixes your issue?
#1277

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.

2 participants