# execute\_process buffering

**URL:** <https://discourse.cmake.org/t/execute-process-buffering/7579>\
**Category:** Code\
**Created:** [March 1, 2023, 11:03pm UTC](https://discourse.cmake.org/t/execute-process-buffering/7579 "2023-03-01T23:03:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baruch\_Burstein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/baruch_burstein/32/3214_2.png) [@Baruch\_Burstein](https://discourse.cmake.org/u/Baruch_Burstein)\
**Post date:** [March 1, 2023, 11:03pm UTC](https://discourse.cmake.org/t/execute-process-buffering/7579/1 "2023-03-01T23:03:39Z")

</div>

I am using `execute_process` to run a process that can take some time (specifically - `docker build`). I want to see the output from the process as it is generated since it lets me know where it is up to and how much longer it will take, but `execute_process` is buffering the output and only dumping it all once the process is finished. How can I get it to show the output as it is generated, without buffering?

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [March 2, 2023, 8:50pm UTC](https://discourse.cmake.org/t/execute-process-buffering/7579/2 "2023-03-02T20:50:25Z")

</div>

Are you using `OUTPUT_VARIABLE` and/or `ERROR_VARIABLE` to capture the output? If so, try `ECHO_OUTPUT_VARIABLE` and `ECHO_ERROR_VARIABLE` instead (requires CMake 3.18 or later).

---

<div class="post-metadata">

**Author:** ![Baruch\_Burstein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/baruch_burstein/32/3214_2.png) [@Baruch\_Burstein](https://discourse.cmake.org/u/Baruch_Burstein)\
**Post date:** [March 9, 2023, 6:59pm UTC](https://discourse.cmake.org/t/execute-process-buffering/7579/3 "2023-03-09T18:59:40Z")

</div>

I am not using either of those. The only thing I am using is `OUTPUT_STRIP_TRAILING_WHITESPACE`

---

<div class="post-metadata">

**Author:** ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)\
**Post date:** [March 10, 2023, 3:45am UTC](https://discourse.cmake.org/t/execute-process-buffering/7579/4 "2023-03-10T03:45:14Z")

</div>

This little experiment shows that `execute_process()` doesn’t print till the process ends or stdout pipe is flushed.  
If you run the Python script directly without CMake, the printing occurs “real time” even when not flushed thought that could be a bit platform-dependent.

> <https://gist.github.com/scivision/62e822cdf6e35b6858933676e5b98cd5>
