1.1 --- a/test_files/programs/test_popenv.c Sun Jun 02 23:10:47 2024 +0200
1.2 +++ b/test_files/programs/test_popenv.c Sun Jun 02 23:15:39 2024 +0200
1.3 @@ -94,11 +94,24 @@
1.4
1.5 printf("Process: %d\n", pid);
1.6
1.7 - /* Prevent stdin from blocking to be able to read as much data as is
1.8 - available and to monitor events on it manually. */
1.9 + /* Make stdin and the pipes non-blocking to be able to read and write as
1.10 + much data as is available and to monitor events on them manually. */
1.11
1.12 if (stdin != NULL)
1.13 + {
1.14 fcntl(fileno(stdin), F_SETFL, O_NONBLOCK | fcntl(fileno(stdin), F_GETFL));
1.15 + fcntl(fileno(input), F_SETFL, O_NONBLOCK | fcntl(fileno(input), F_GETFL));
1.16 + }
1.17 + else
1.18 + {
1.19 + fclose(input);
1.20 + input = NULL;
1.21 + }
1.22 +
1.23 + fcntl(fileno(output), F_SETFL, O_NONBLOCK | fcntl(fileno(output), F_GETFL));
1.24 +
1.25 + if (error != NULL)
1.26 + fcntl(fileno(error), F_SETFL, O_NONBLOCK | fcntl(fileno(error), F_GETFL));
1.27
1.28 /* Monitor the streams and the process. */
1.29
1.30 @@ -136,6 +149,7 @@
1.31
1.32 if ((source == port_file_source(fileno(stdin))) ||
1.33 input_remaining || (source == port_file_source(fileno(input))))
1.34 +
1.35 transfer(stdin, input, input_buffer, &input_start, &input_remaining);
1.36
1.37 /* If no input remains and stdin has been closed, close the input