1.1 --- a/tests/dstest_exec.cc Wed Jan 24 21:12:41 2024 +0100
1.2 +++ b/tests/dstest_exec.cc Wed Jan 24 21:17:37 2024 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * A test of executing code in new tasks and threads.
1.6 *
1.7 - * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2022, 2023, 2024 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -41,22 +41,31 @@
1.13 static long test_process(int argc, const char *argv[])
1.14 {
1.15 process_t *process;
1.16 - file_t *reader, *writer;
1.17 + file_t *input_reader, *input_writer;
1.18 + file_t *output_reader, *output_writer;
1.19 long err;
1.20
1.21 - /* Create a pipe for process output. */
1.22 + /* Create pipes for process input and output. */
1.23
1.24 - err = client_pipe(&reader, &writer, 0);
1.25 + err = client_pipe(&input_reader, &input_writer, 0);
1.26
1.27 if (err)
1.28 {
1.29 - printf("Could not obtain pipe: %s\n", l4sys_errtostr(err));
1.30 + printf("Could not obtain pipe for input: %s\n", l4sys_errtostr(err));
1.31 + return err;
1.32 + }
1.33 +
1.34 + err = client_pipe(&output_reader, &output_writer, 0);
1.35 +
1.36 + if (err)
1.37 + {
1.38 + printf("Could not obtain pipe for output: %s\n", l4sys_errtostr(err));
1.39 return err;
1.40 }
1.41
1.42 /* Start the process. */
1.43
1.44 - err = process_spawn(argc, argv, writer, &process);
1.45 + err = process_spawn(argc, argv, input_reader, output_writer, &process);
1.46
1.47 if (err)
1.48 {
1.49 @@ -66,9 +75,10 @@
1.50
1.51 printf("Finished program initiation.\n");
1.52
1.53 - /* Release the writing end of the pipe. */
1.54 + /* Release the relinquished ends of the pipes. */
1.55
1.56 - client_close(writer);
1.57 + client_close(input_reader);
1.58 + client_close(output_writer);
1.59
1.60 /* Read until the pipe yields no more data. */
1.61
1.62 @@ -76,7 +86,7 @@
1.63
1.64 while (1)
1.65 {
1.66 - offset_t nread = client_read(reader, buffer, TO_TRANSFER);
1.67 + offset_t nread = client_read(output_reader, buffer, TO_TRANSFER);
1.68
1.69 if (nread)
1.70 fwrite(buffer, sizeof(char), nread, stdout);
1.71 @@ -84,9 +94,10 @@
1.72 break;
1.73 }
1.74
1.75 - /* Close the pipe and obtain the process state. */
1.76 + /* Close the pipes and obtain the process state. */
1.77
1.78 - client_close(reader);
1.79 + client_close(input_writer);
1.80 + client_close(output_reader);
1.81
1.82 notify_flags_t flags;
1.83 notify_values_t values;