1.1 --- a/libexec/include/exec/process.h Sun Mar 19 00:48:15 2023 +0100
1.2 +++ b/libexec/include/exec/process.h Sun Mar 19 00:49:19 2023 +0100
1.3 @@ -89,6 +89,8 @@
1.4 public:
1.5 explicit Process();
1.6
1.7 + void reset();
1.8 +
1.9 l4_cap_idx_t allocate_cap();
1.10
1.11 long configure_task(l4_cap_idx_t *task, l4_cap_idx_t *mapped_task,
2.1 --- a/libexec/include/exec/process_creating.h Sun Mar 19 00:48:15 2023 +0100
2.2 +++ b/libexec/include/exec/process_creating.h Sun Mar 19 00:49:19 2023 +0100
2.3 @@ -21,6 +21,8 @@
2.4
2.5 #pragma once
2.6
2.7 +#include <mutex>
2.8 +
2.9 #include <exec/elf.h>
2.10 #include <exec/external_pager.h>
2.11 #include <exec/memory.h>
2.12 @@ -34,6 +36,10 @@
2.13 class ProcessCreating
2.14 {
2.15 protected:
2.16 + std::mutex _lock;
2.17 +
2.18 + /* Region mapper program filename. */
2.19 +
2.20 const char *_rm_filename;
2.21
2.22 /* External pager configuration. */
3.1 --- a/libexec/lib/src/process.cc Sun Mar 19 00:48:15 2023 +0100
3.2 +++ b/libexec/lib/src/process.cc Sun Mar 19 00:49:19 2023 +0100
3.3 @@ -54,6 +54,11 @@
3.4
3.5 Process::Process()
3.6 {
3.7 + reset();
3.8 +}
3.9 +
3.10 +void Process::reset()
3.11 +{
3.12 _thread_number = 0;
3.13
3.14 /* Populate the common initial environment for the threads. */
3.15 @@ -89,6 +94,11 @@
3.16
3.17 long Process::create_task(unsigned int threads)
3.18 {
3.19 + /* Reset the process if it has already been used. */
3.20 +
3.21 + if (_thread_number)
3.22 + reset();
3.23 +
3.24 _task = ipc_cap_alloc();
3.25
3.26 if (l4_is_invalid_cap(_task))
4.1 --- a/libexec/lib/src/process_creating.cc Sun Mar 19 00:48:15 2023 +0100
4.2 +++ b/libexec/lib/src/process_creating.cc Sun Mar 19 00:49:19 2023 +0100
4.3 @@ -348,12 +348,14 @@
4.4
4.5 long ProcessCreating::start(int argc, const char *argv[], l4_cap_idx_t *process)
4.6 {
4.7 - file_t *file = client_open(argv[0], O_RDONLY);
4.8 - long err;
4.9 + std::lock_guard<std::mutex> guard(_lock);
4.10
4.11 /* Open the program file, handling any error conditions. If successfully
4.12 opened, it will be closed when the process terminates. */
4.13
4.14 + file_t *file = client_open(argv[0], O_RDONLY);
4.15 + long err;
4.16 +
4.17 if (file == NULL)
4.18 return -L4_EIO;
4.19