Skip to content

Conversation

@gspencergoog
Copy link
Contributor

Description

In my last change, I had switched to processManager.killPid(process.pid) to kill a process because it was easier to test, but that doesn't appear to actually work. It works fine in tests, which is why I didn't catch it, but it doesn't actually kill the process in the real app.

Seems like a bug in ProcessManager, but maybe there's something subtle happening here. In any case, this now kills processes properly.

Tests

  • Removed the test for what processes were killed by the process manager, since it's no longer doing that. I don't see a good way to test if process.kill() was called...

@github-actions
Copy link

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

@gspencergoog gspencergoog marked this pull request as draft October 22, 2025 21:45
@jakemac53
Copy link
Contributor

@gspencergoog I looked at the implementation and it just calls Process.killPid from dart:io so that seems very odd indeed... https://github.com/dart-lang/tools/blob/main/pkgs/process/lib/src/interface/local_process_manager.dart#L128

@jakemac53
Copy link
Contributor

Fwiw, are you sure flutter isn't expecting two sigterm signals in order to shut down?

'TimeoutException',
]),
);
test.expect(mockProcessManager.killedPids, [processPid]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to look for the mocked processes here and then check if they were killed

@gspencergoog
Copy link
Contributor Author

I agree with all of that... except it still doesn't kill the app even with process.kill(), which is why I converted back to draft. It seems to kill only the flutter shell, and not the child processes.

@gspencergoog
Copy link
Contributor Author

gspencergoog commented Oct 22, 2025

When I do a kill -HUP or kill -TERM on the flutter process (on Linux) from the command line, it is exiting, and it's taking down one child, but it leaves the dart develop command and the app running. It kills the flutter command (the main process) and the frontend_server_aot.dart.snapshot.

@gspencergoog
Copy link
Contributor Author

gspencergoog commented Oct 22, 2025

It works just fine on macOS, even with using the process manager to kill it.

@gspencergoog
Copy link
Contributor Author

Okay, this works, but I'm not sure if it's too much of a hack. It should work on all the Linux systems that Flutter supports.

@gspencergoog gspencergoog marked this pull request as ready for review October 22, 2025 23:07
@jakemac53
Copy link
Contributor

flutter run also supports sending a q character to exit, maybe we should try just sending that?

@gspencergoog
Copy link
Contributor Author

flutter run also supports sending a q character to exit, maybe we should try just sending that?

I thought about that, but it doesn't listen to stdin with --machine. And the DTD URI isn't printed in web without --machine (this is a temporary oversight, but currently the case).

@jakemac53
Copy link
Contributor

jakemac53 commented Oct 23, 2025

https://github.com/flutter/flutter/blob/efc4d23cf0af636dd4997ad56d784a00ec206e0b/packages/flutter_tools/doc/daemon.md?plain=1#L13

Looks like it actually supports a whole protocol, so we can send a shutdown message?

We may actually want to consider running using flutter daemon in general here? Then we can use app.start and app.stop etc.

@gspencergoog
Copy link
Contributor Author

We may actually want to consider running using flutter daemon in general here? Then we can use app.start and app.stop etc.

Oooh, yeah, that's probably the right call. Okay, I'll look at that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants