Skip to content

A debug build doesn't exit when run without a debugger #3

Open

Description

@Jarrio

A program built with -debug and hxcpp-debug-server never exits when it runs without a debugger.

When connect() fails at startup, waitForAttach() starts a haxe.Timer that runs every 500 ms on the main thread, so that a debugger attaching later can be handled there. The timer keeps the main event loop alive, so the program carries on after main returns.

Seen with Haxe 4.3.7 and the Haxe 5 preview: timeout 5 ./bin/cpp/Main-debug prints the program's output and is then killed after 5 seconds.

This is upstream's code, from before this fork. It doesn't affect sessions started from a debugger, where connect() succeeds. Ways to fix it:

  • an event that doesn't keep the loop alive (haxe.MainLoop.add(...) with isBlocking = false on Haxe 4; Haxe 5's event loop needs checking)
  • waiting for an attach only when asked to, through an environment variable or a define
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions