1.1 --- a/libfsclient/lib/src/process.cc Tue Feb 28 22:35:25 2023 +0100
1.2 +++ b/libfsclient/lib/src/process.cc Tue Feb 28 22:40:02 2023 +0100
1.3 @@ -25,7 +25,7 @@
1.4 #include <stdio.h>
1.5 #include <stdlib.h>
1.6
1.7 -#include "process_creator_client.h"
1.8 +#include "process_creator_context_client.h"
1.9
1.10 #include "file.h"
1.11 #include "process.h"
1.12 @@ -58,24 +58,47 @@
1.13 process->notifiable.base = (notifiable_base_t *) process;
1.14 }
1.15
1.16 -/* Start a process using the given file as payload.
1.17 - NOTE: This does not yet communicate arguments or obtain input/output
1.18 - pipes. */
1.19 +/* Start a process using the given arguments.
1.20 + NOTE: This does not yet obtain input/output pipes. */
1.21
1.22 -long process_start(process_t *process, file_t *file)
1.23 +long process_start(process_t *process, int argc, char *argv[])
1.24 {
1.25 l4_cap_idx_t server = l4re_env_get_cap("pserver");
1.26
1.27 if (l4_is_invalid_cap(server))
1.28 return -L4_ENOMEM;
1.29
1.30 - /* Obtain a client for the process creator. */
1.31 + /* Obtain a context for process creation. */
1.32 +
1.33 + file_t context;
1.34 + long err = file_context(&context, server);
1.35 +
1.36 + if (err)
1.37 + return err;
1.38 +
1.39 + offset_t pos = 0, written;
1.40
1.41 - client_ProcessCreator creator(server);
1.42 + for (int i = 0; i < argc; i++)
1.43 + {
1.44 + if (!file_string_set(&context, argv[i], pos, &written))
1.45 + return -L4_ENOMEM;
1.46 +
1.47 + pos += written + 1;
1.48 + }
1.49 +
1.50 + /* Obtain a client for the process creator context. */
1.51 +
1.52 + client_ProcessCreatorContext creator(context.ref);
1.53
1.54 /* Start the process, obtaining a reference to it. */
1.55
1.56 - return creator.start(file->ref, &process->ref);
1.57 + err = creator.start(argc, &process->ref);
1.58 +
1.59 + /* Close the context, although a separate mechanism could permit contexts to
1.60 + open several processes. */
1.61 +
1.62 + file_close(&context);
1.63 + return err;
1.64 }
1.65
1.66