1.1 --- a/libexec/lib/src/process_creating.cc Mon Mar 06 19:12:48 2023 +0100
1.2 +++ b/libexec/lib/src/process_creating.cc Tue Mar 07 00:43:52 2023 +0100
1.3 @@ -21,9 +21,11 @@
1.4
1.5 #include <l4/re/env.h>
1.6
1.7 +#include <fsclient/client.h>
1.8 #include <fsserver/resource_server.h>
1.9 #include <ipc/cap_alloc.h>
1.10 #include <ipc/map.h>
1.11 +#include <systypes/fcntl.h>
1.12
1.13 #include <stdio.h>
1.14
1.15 @@ -306,13 +308,29 @@
1.16 return L4_EOK;
1.17 }
1.18
1.19 -/* Start a new process for the given payload, providing the indicated program
1.20 - arguments, returning a reference to the pager. */
1.21 +/* Start a new process for the payload indicated by the first of the given
1.22 + program arguments, returning a reference to the pager as an object for
1.23 + interacting with the process. */
1.24 +
1.25 +long ProcessCreating::start(int argc, const char *argv[], l4_cap_idx_t *process)
1.26 +{
1.27 + file_t *file = client_open(argv[0], O_RDONLY);
1.28 + long err;
1.29 +
1.30 + /* Open the program file, handling any error conditions. If successfully
1.31 + opened, it will be closed when the process terminates. */
1.32
1.33 -long ProcessCreating::start(file_t *file, int argc, const char *argv[],
1.34 - l4_cap_idx_t *process)
1.35 -{
1.36 - long err;
1.37 + if (file == NULL)
1.38 + return -L4_EIO;
1.39 +
1.40 + if (!client_opened(file))
1.41 + {
1.42 + err = file->error;
1.43 + client_close(file);
1.44 + return err;
1.45 + }
1.46 +
1.47 + /* Initialise the different elements of the process. */
1.48
1.49 err = init_region_mapper();
1.50 if (err)
1.51 @@ -344,7 +362,8 @@
1.52
1.53 /* Discard instances created to initialise the process. The region mapper
1.54 relies on resources associated with its payload and stack and so these
1.55 - cannot be deleted immediately.
1.56 + cannot be deleted immediately. Instead, they are released when the pager is
1.57 + deallocated.
1.58
1.59 NOTE: The region mapper payload could be retained instead of being
1.60 reconstructed each time. */