-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
Out_channel.{is,set}_buffered
to control buffering of output ch…
…annels (#10538)
- Loading branch information
Showing
8 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(* TEST *) | ||
|
||
(* baseline *) | ||
let () = | ||
print_string "stdout 1\n"; | ||
prerr_string "stderr 1\n"; | ||
flush stdout; | ||
flush stderr | ||
|
||
(* stderr unbuffered *) | ||
let () = | ||
Out_channel.set_buffered stderr false; | ||
print_string "stdout 2\n"; | ||
prerr_string "stderr 2\n"; | ||
print_string (Bool.to_string (Out_channel.is_buffered stderr)); | ||
print_char '\n'; | ||
flush stdout | ||
|
||
(* switching to unbuffered flushes the channel *) | ||
let () = | ||
print_string "stdout 3\n"; | ||
prerr_string "stderr 3\n"; | ||
Out_channel.set_buffered stderr false; | ||
flush stdout | ||
|
||
(* stderr back to buffered *) | ||
let () = | ||
Out_channel.set_buffered stderr true; | ||
print_string "stdout 4\n"; | ||
prerr_string "stderr 4\n"; | ||
print_string (Bool.to_string (Out_channel.is_buffered stderr)); | ||
print_char '\n'; | ||
flush stdout; | ||
flush stderr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
stdout 1 | ||
stderr 1 | ||
stderr 2 | ||
stdout 2 | ||
false | ||
stderr 3 | ||
stdout 3 | ||
stdout 4 | ||
true | ||
stderr 4 |