Skip to content

bin\crystal run wrapper does not terminate if interrupts are ignored #14960

Open
@HertzDevil

Description

@HertzDevil

If Ctrl+C is ignored, naturally it becomes impossible to terminate the file being executed with crystal run using that shortcut. The same also applies to the bin/crystal script, because it uses exec to run the compiler, but not to bin\crystal.bat and bin\crystal.ps1, since Windows does not have a real exec equivalent. Thus if the following script is run:

Process.ignore_interrupts!
sleep
# minimal alternative for the empty prelude

lib LibC
  alias DWORD = UInt32
  alias BOOL = Int32

  fun SetConsoleCtrlHandler(handlerRoutine : DWORD -> BOOL, add : BOOL) : BOOL
  fun Sleep(dwMilliseconds : DWORD)
end

LibC.SetConsoleCtrlHandler(nil, 1)
LibC.Sleep(-1)

then Ctrl+C still exits the wrapper, leaving both the compiler and the compiled code running. This is problematic because if the user then attempts to run the same code again, a linker error occurs as overwriting a running process's file is not allowed on Windows. The only way out is to manually terminate the running code from Task Manager.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status

      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions