# HG changeset patch # User Paul Boddie # Date 1717362939 -7200 # Node ID b50b211205b7a61d8c7442771df4443d14fd8600 # Parent c8dc71d81ab4fc760045166ae64dd02ff288b4fe Make pipes non-blocking now that popenv returns blocking pipes. diff -r c8dc71d81ab4 -r b50b211205b7 test_files/programs/test_popenv.c --- a/test_files/programs/test_popenv.c Sun Jun 02 23:10:47 2024 +0200 +++ b/test_files/programs/test_popenv.c Sun Jun 02 23:15:39 2024 +0200 @@ -94,11 +94,24 @@ printf("Process: %d\n", pid); - /* Prevent stdin from blocking to be able to read as much data as is - available and to monitor events on it manually. */ + /* Make stdin and the pipes non-blocking to be able to read and write as + much data as is available and to monitor events on them manually. */ if (stdin != NULL) + { fcntl(fileno(stdin), F_SETFL, O_NONBLOCK | fcntl(fileno(stdin), F_GETFL)); + fcntl(fileno(input), F_SETFL, O_NONBLOCK | fcntl(fileno(input), F_GETFL)); + } + else + { + fclose(input); + input = NULL; + } + + fcntl(fileno(output), F_SETFL, O_NONBLOCK | fcntl(fileno(output), F_GETFL)); + + if (error != NULL) + fcntl(fileno(error), F_SETFL, O_NONBLOCK | fcntl(fileno(error), F_GETFL)); /* Monitor the streams and the process. */ @@ -136,6 +149,7 @@ if ((source == port_file_source(fileno(stdin))) || input_remaining || (source == port_file_source(fileno(input)))) + transfer(stdin, input, input_buffer, &input_start, &input_remaining); /* If no input remains and stdin has been closed, close the input