1.1 --- a/libexec/include/exec/process_creating.h Mon Mar 06 19:12:48 2023 +0100
1.2 +++ b/libexec/include/exec/process_creating.h Tue Mar 07 00:43:52 2023 +0100
1.3 @@ -82,7 +82,7 @@
1.4 public:
1.5 explicit ProcessCreating(const char *rm_filename);
1.6
1.7 - virtual long start(file_t *file, int argc, const char *argv[], l4_cap_idx_t *process);
1.8 + virtual long start(int argc, const char *argv[], l4_cap_idx_t *process);
1.9 };
1.10
1.11 /* vim: tabstop=2 expandtab shiftwidth=2
2.1 --- a/libexec/lib/src/process_creating.cc Mon Mar 06 19:12:48 2023 +0100
2.2 +++ b/libexec/lib/src/process_creating.cc Tue Mar 07 00:43:52 2023 +0100
2.3 @@ -21,9 +21,11 @@
2.4
2.5 #include <l4/re/env.h>
2.6
2.7 +#include <fsclient/client.h>
2.8 #include <fsserver/resource_server.h>
2.9 #include <ipc/cap_alloc.h>
2.10 #include <ipc/map.h>
2.11 +#include <systypes/fcntl.h>
2.12
2.13 #include <stdio.h>
2.14
2.15 @@ -306,13 +308,29 @@
2.16 return L4_EOK;
2.17 }
2.18
2.19 -/* Start a new process for the given payload, providing the indicated program
2.20 - arguments, returning a reference to the pager. */
2.21 +/* Start a new process for the payload indicated by the first of the given
2.22 + program arguments, returning a reference to the pager as an object for
2.23 + interacting with the process. */
2.24 +
2.25 +long ProcessCreating::start(int argc, const char *argv[], l4_cap_idx_t *process)
2.26 +{
2.27 + file_t *file = client_open(argv[0], O_RDONLY);
2.28 + long err;
2.29 +
2.30 + /* Open the program file, handling any error conditions. If successfully
2.31 + opened, it will be closed when the process terminates. */
2.32
2.33 -long ProcessCreating::start(file_t *file, int argc, const char *argv[],
2.34 - l4_cap_idx_t *process)
2.35 -{
2.36 - long err;
2.37 + if (file == NULL)
2.38 + return -L4_EIO;
2.39 +
2.40 + if (!client_opened(file))
2.41 + {
2.42 + err = file->error;
2.43 + client_close(file);
2.44 + return err;
2.45 + }
2.46 +
2.47 + /* Initialise the different elements of the process. */
2.48
2.49 err = init_region_mapper();
2.50 if (err)
2.51 @@ -344,7 +362,8 @@
2.52
2.53 /* Discard instances created to initialise the process. The region mapper
2.54 relies on resources associated with its payload and stack and so these
2.55 - cannot be deleted immediately.
2.56 + cannot be deleted immediately. Instead, they are released when the pager is
2.57 + deallocated.
2.58
2.59 NOTE: The region mapper payload could be retained instead of being
2.60 reconstructed each time. */
3.1 --- a/libexec/lib/src/process_creator_resource.cc Mon Mar 06 19:12:48 2023 +0100
3.2 +++ b/libexec/lib/src/process_creator_resource.cc Tue Mar 07 00:43:52 2023 +0100
3.3 @@ -20,7 +20,6 @@
3.4 */
3.5
3.6 #include <fsserver/resource_server.h>
3.7 -#include <systypes/fcntl.h>
3.8
3.9 #include "opener_server.h"
3.10 #include "process_creating.h"
3.11 @@ -49,17 +48,19 @@
3.12
3.13 /* ProcessCreator interface methods. */
3.14
3.15 +/* Start the new process, obtaining a reference to it. */
3.16 +
3.17 long ProcessCreatorResource::start(int argc, const char *argv[], l4_cap_idx_t *process)
3.18 {
3.19 - file_t *program_file = client_open(argv[0], O_RDONLY);
3.20 -
3.21 - /* Start the new process, obtaining a reference to it. */
3.22 -
3.23 - return _creating.start(program_file, argc, argv, process);
3.24 + return _creating.start(argc, argv, process);
3.25 }
3.26
3.27 +
3.28 +
3.29 /* Opener interface methods. */
3.30
3.31 +/* Return a context, through which program arguments must be communicated. */
3.32 +
3.33 long ProcessCreatorResource::context(l4_cap_idx_t *context)
3.34 {
3.35 ProcessCreatorContextResource *resource = new ProcessCreatorContextResource(this);