diff --git a/resize/progress-c.c b/resize/progress-c.c index 2f25bbcc2..2813d0cf4 100644 --- a/resize/progress-c.c +++ b/resize/progress-c.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -103,3 +104,12 @@ virt_resize_progress_bar_set (value barv, CAMLreturn (Val_unit); } + +/* RHEL 5-era ocaml didn't have Unix.isatty. */ +value +virt_resize_isatty_stdout (value unitv) +{ + CAMLparam1 (unitv); + + CAMLreturn (isatty(1) ? Val_true : Val_false); +} diff --git a/resize/progress.ml b/resize/progress.ml index 7a94c6c6e..1ff73c225 100644 --- a/resize/progress.ml +++ b/resize/progress.ml @@ -28,12 +28,13 @@ external progress_bar_reset : progress_bar -> unit = "virt_resize_progress_bar_reset" external progress_bar_set : progress_bar -> int64 -> int64 -> unit = "virt_resize_progress_bar_set" +external isatty_stdout : unit -> bool = "virt_resize_isatty_stdout" let set_up_progress_bar ?(machine_readable = false) (g : Guestfs.guestfs) = (* Only display progress bars if the machine_readable flag is set or * the output is a tty. *) - if machine_readable || isatty stdout then ( + if machine_readable || isatty_stdout () then ( (* Initialize the C mini library. *) let bar = progress_bar_init ~machine_readable in