Skip to content

control-C does not exit app on iOS device from flutter run #4875

Open

Description

@eseidelGoogle
Application running.
Type "h" or F1 for help and "q", F10, or ctrl-c to quit.
Type "w" to print the widget hierarchy of the app, and "t" for the render tree.
^CApplication finished.

Seems we should either fix the instructions or fix the behavior. I don't really care which. :)

Activity

  1. added
    platform-iosiOS applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Jul 11, 2016
  2. changed the title [-]control-C does not exist app on iOS device from `flutter run`[/-] [+]control-C does not exit app on iOS device from `flutter run`[/+] on Jul 18, 2016
  3. modified the milestone: on Sep 12, 2016
  4. modified the milestones: , on Jan 31, 2017
  5. cbracken commented on Mar 31, 2017

    @cbracken
    Member

    Instructions no longer include ctrl-c to quit.

  6. Hixie commented on Mar 31, 2017

    @Hixie
    Contributor

    Why doesn't ^C exit the process on Mac?

  7. cbracken commented on Apr 1, 2017

    @cbracken
    Member

    Just tested on Android and as you note, even though we don't make the promise anymore, there's a definite difference in behaviour. Re-opening.

    Here's what appears to be going on. When the terminal receives ctrl-c, it sends SIGINT to the processgroup. On iOS, one of the child processes of flutter tool is iproxy, which manages all the port forwarding we do -- in this case, that includes the observatory port forwarding. iproxy gets SIGINT and dies, which kills our observatory connection.

    The stopApp call that we do in the SIGINT handler gets called and tries to issue an ext.flutter.exit call to the VM service to shutdown the running Flutter app on the device... but the VM service connection is dead so it never gets the shutdown call.

    As a test, instead of starting iproxy directly, I patched the tool to start it through a wrapper script that traps and ignores SIGINT and everything ran nicely as expected.

    Why doesn't this happen for Android? adb doesn't stay running as a child process, it starts its own daemon off to the side.

  8. eseidelGoogle commented on Apr 1, 2017

    @eseidelGoogle
    ContributorAuthor

    It's also possible to catch the SIGINT from the dart script and have some sort of orderly shutdown I would imagine? In any case, whatever you decide is fine. :) I recall we had to catch SIGINT in Webkit's python testing script (as KeyboardInterrupt) to do a bunch of orderly shutdown stuff.

  9. Hixie commented on Apr 1, 2017

    @Hixie
    Contributor

    We do catch it in the Dart script, but for some reason it also hits iproxy.

  10. cbracken commented on Apr 1, 2017

    @cbracken
    Member

    Yep. I'll play around a bit with it and do some digging over the weekend to see what we can do. I've got a workaround, but it's a hack and there's almost certainly a simple, proper way to do this.

    I'm not 100% convinced I'm right about iproxy getting the SIGINT. Something is definitely killing it, which is the source of the naughty behaviour, but in local testing with a contrived example, I see the expected behaviour of only the parent receiving SIGINT. Will try to get a clear picture of how we're killing it over the weekend and get a fix together.

  11. 3 remaining items

  12. modified the milestones: , on Jan 7, 2020
  13. added
    P3Issues that are less important to the Flutter project
    on May 29, 2020
  14. modified the milestone: on Jun 1, 2020
  15. removed this from the milestone on Jun 16, 2020
  16. removed this from the milestone on Jul 7, 2020
  17. modified the milestone: on Jul 22, 2020
  18. removed this from the milestone on Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions