CMake/Tests/RunCMake/print_stdin.c
Brad King 86e8315482 CTest: Restore inheritance of stdin by test processes
Since commit v3.11.0-rc1~117^2 (CTest: Re-implement test process
handling using libuv, 2017-12-10) we do not give the child test
processes any stdin.  Prior to that change we let the child test
processes inherit stdin from ctest itself.  Tests that run serially
might be able to use the real stdin meaningfully, so restore that
behavior and add a test case.

Fixes: #18591
2018-11-15 08:08:56 -05:00

19 lines
310 B
C

#include <stdio.h>
int main()
{
char buf[1024];
size_t nIn = sizeof(buf);
while (nIn == sizeof(buf)) {
nIn = fread(buf, 1, sizeof(buf), stdin);
if (nIn > 0) {
size_t nOut;
nOut = fwrite(buf, 1, nIn, stdout);
if (nOut != nIn) {
return 1;
}
}
}
return 0;
}