Skip to content

Commit

Permalink
If connected to a terminal, set stderr to be unbuffered
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb committed Jul 24, 2021
1 parent 456afd1 commit 972eae0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions stdlib/stdlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,17 @@ external open_descriptor_out : int -> out_channel
= "caml_ml_open_descriptor_out"
external open_descriptor_in : int -> in_channel = "caml_ml_open_descriptor_in"

external set_channel_unbuffered : out_channel -> unit = "caml_ml_set_channel_unbuffered"

let stdin = open_descriptor_in 0
let stdout = open_descriptor_out 1
let stderr = open_descriptor_out 2

external isatty : out_channel -> bool = "caml_sys_isatty"

let () =
if isatty stderr then set_channel_unbuffered stderr

(* General output functions *)

type open_flag =
Expand Down

0 comments on commit 972eae0

Please sign in to comment.