Skip to content

catch_break does not always catch break #3747

@vicuna

Description

@vicuna

Original bug ID: 3747
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Target version: later
Category: runtime system and C interface

Bug description

Full_Name: Henri
Version: 3.08.2
OS: linux
Submission from: aorleans-104-1-15-86.w80-11.abo.wanadoo.fr (80.11.35.86)

The following program never catches Ctrl+C in a terminal and loops forever.

let _ =
  Sys.catch_break true;
  try 
    while true do
      ()
    done
  with 
    Sys.Break -> prerr_endline "QUIT!"

The following program works as expected though!

let _ =
  Sys.catch_break true;
  try 
    while true do
      ignore (input_line stdin)
    done
  with 
    Sys.Break -> prerr_endline "QUIT!"

The following program does not catch break of course, but exits properly when
Ctrl+C is pressed in the same environment.

let _ =
  try 
    while true do
      ()
    done
  with 
    Sys.Break -> prerr_endline "QUIT!" (* useless, kept anyway *)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions