1.1 --- a/tests/dstest_exec.cc Tue Dec 12 19:16:58 2023 +0100
1.2 +++ b/tests/dstest_exec.cc Tue Dec 12 19:20:09 2023 +0100
1.3 @@ -44,13 +44,9 @@
1.4 file_t *reader, *writer;
1.5 long err;
1.6
1.7 - /* Obtain the common notifier. */
1.8 -
1.9 - notifier_t *notifier = client_notifier_task();
1.10 -
1.11 /* Create a pipe for process output. */
1.12
1.13 - err = client_pipe(&reader, &writer, O_NONBLOCK);
1.14 + err = client_pipe(&reader, &writer, 0);
1.15
1.16 if (err)
1.17 {
1.18 @@ -58,14 +54,6 @@
1.19 return err;
1.20 }
1.21
1.22 - err = client_subscribe(reader, NOTIFY_CONTENT_AVAILABLE | NOTIFY_PEER_CLOSED, notifier);
1.23 -
1.24 - if (err)
1.25 - {
1.26 - printf("Could not subscribe to pipe notifications: %s\n", l4sys_errtostr(err));
1.27 - return err;
1.28 - }
1.29 -
1.30 /* Start the process. */
1.31
1.32 err = process_spawn(argc, argv, writer, &process);
1.33 @@ -82,59 +70,30 @@
1.34
1.35 client_close(writer);
1.36
1.37 - /* Wait for a signal from the process or input from the process. */
1.38 -
1.39 - err = notify_subscribe(process_notifiable(process), NOTIFY_TASK_ALL, notifier);
1.40 + /* Read until the pipe yields no more data. */
1.41
1.42 - if (err)
1.43 - {
1.44 - printf("Could not subscribe to task notifications: %s\n", l4sys_errtostr(err));
1.45 - return err;
1.46 - }
1.47 -
1.48 - notifiable_t *notifiable;
1.49 + char buffer[TO_TRANSFER];
1.50
1.51 while (1)
1.52 {
1.53 - err = notify_wait_many(¬ifiable, notifier);
1.54 -
1.55 - if (err)
1.56 - {
1.57 - printf("Could not wait for process: %s\n", l4sys_errtostr(err));
1.58 - return err;
1.59 - }
1.60 -
1.61 - /* Handle any signal. */
1.62 -
1.63 - if (notifiable == process_notifiable(process))
1.64 - break;
1.65 + offset_t nread = client_read(reader, buffer, TO_TRANSFER);
1.66
1.67 - /* Handle any input. */
1.68 -
1.69 - else if (notifiable == file_notifiable(reader))
1.70 - {
1.71 - char buffer[TO_TRANSFER];
1.72 - offset_t nread = client_read(reader, buffer, TO_TRANSFER);
1.73 -
1.74 - while (nread)
1.75 - {
1.76 - fwrite(buffer, sizeof(char), nread, stdout);
1.77 - nread = client_read(reader, buffer, TO_TRANSFER);
1.78 - }
1.79 - }
1.80 + if (nread)
1.81 + fwrite(buffer, sizeof(char), nread, stdout);
1.82 + else
1.83 + break;
1.84 }
1.85
1.86 - notify_flags_t flags = process_notifications(process);
1.87 - notify_values_t values = process_notification_values(process);
1.88 + /* Close the pipe and obtain the process state. */
1.89 +
1.90 + client_close(reader);
1.91 +
1.92 + notify_flags_t flags;
1.93 + notify_values_t values;
1.94 +
1.95 + err = process_wait(process, &flags, &values);
1.96
1.97 printf("End process (flags %" pFMTnotify_flags "x values: %ld, %ld)\n", flags, values.sig, values.val);
1.98 - printf("End reader (flags %" pFMTnotify_flags "x)\n", file_notifications(reader));
1.99 -
1.100 - err = process_error(process);
1.101 -
1.102 - client_close(reader);
1.103 - process_free(process);
1.104 - client_notifier_close(notifier);
1.105
1.106 return err;
1.107 }