Skip to content

fix: forward termination signals to proxied Flutter commands - #1082

Open
cdeil wants to merge 1 commit into
btwld:mainfrom
cdeil:fix/forward-termination-signals
Open

cdeil wants to merge 1 commit into
btwld:mainfrom
cdeil:fix/forward-termination-signals

Conversation

@cdeil

@cdeil cdeil commented Nov 2, 2026

Copy link
Copy Markdown

Problem

FVM runs Flutter as a child process and waits for it. ProcessService.run handles only SIGINT, and only when stdin is a terminal (#1054). That covers Ctrl+C, which the terminal also delivers to Flutter itself. A SIGTERM or SIGHUP that another program sends to the FVM process, such as a test runner, an IDE, a CI timeout or timeout(1), ends FVM at once through Dart's default handler. The Flutter tool and the processes it started keep running, with PID 1 as their parent.

To reproduce in any project with an .fvmrc (macOS, FVM 4.3.2, Flutter 3.47.8):

fvm flutter run -d web-server &
kill -TERM $!   # the FVM process
ps -ax | grep -E 'flutter_tools.snapshot|frontend_server'

The Flutter tool and its frontend_server are still running. Plain flutter run exits cleanly on the same signal.

We ran into this with Patrol, which stops flutter run with SIGTERM when it is configured with --flutter-command="fvm flutter". Every web test run left the Flutter tool and its frontend_server behind, about 2.6 GB RSS on Linux.

Change

  • Forward SIGTERM and SIGHUP, and SIGINT when stdin is not a terminal, to the proxied command.
  • Wait for the child to exit, then exit with 128 + the signal number through ForceExit, like the existing SIGINT path.
  • Deliver a signal that arrives before the child has started right after it starts.
  • Windows is unchanged.

On POSIX the child starts through /bin/sh -c. The shell runs the single command with exec, so the forwarded signal reaches Flutter.

Testing

  • The new test/src/services/process_service_signal_forwarding_test.dart starts an FVM parent without a terminal and a signal-aware child, sends SIGTERM or SIGHUP to the parent only, and checks that the child finished its cleanup before the parent exited with 143 or 129. Both cases fail without this change, because the child never receives the signal, and pass with it.
  • process_service_test.dart and the SIGINT PTY test still pass. dart analyze --fatal-infos and dart format are clean. I could not run dcm analyze lib locally.
  • Added a CHANGELOG entry under "Unreleased".

FVM handled only SIGINT from a terminal, which the terminal also sends
to Flutter itself. When another program sent SIGTERM to the FVM
process, for example patrol test stopping `fvm flutter run`, Dart's
default handler ended FVM at once and the Flutter tool and its
frontend_server kept running with PID 1 as parent.

Forward SIGTERM and SIGHUP, and SIGINT when stdin is not a terminal, to
the child, wait for it to exit, then exit with 128 + the signal number.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown

@cdeil is attempting to deploy a commit to the FlutterTools Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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